svn commit: r366866 - in head: include lib/libc/stdlib
Author: delphij Date: Tue Oct 20 01:29:45 2020 New Revision: 366866 URL: https://svnweb.freebsd.org/changeset/base/366866 Log: Further refinements of ptsname_r(3) interface: - Hide ptsname_r under __BSD_VISIBLE for now as the specification is not finalized at this time. - Keep Symbol.map sorted. - Avoid the interposing of ptsname_r(3) from an user application from breaking ptsname(3) by making the implementation a static method and call the static function from ptsname(3) instead. Reported by: kib Reviewed by: kib, jilles MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D26845 Modified: head/include/stdlib.h head/lib/libc/stdlib/Symbol.map head/lib/libc/stdlib/ptsname.c Modified: head/include/stdlib.h == --- head/include/stdlib.h Mon Oct 19 22:32:36 2020(r366865) +++ head/include/stdlib.h Tue Oct 20 01:29:45 2020(r366866) @@ -211,7 +211,6 @@ double drand48(void); double erand48(unsigned short[3]); /* char*fcvt(double, int, int * __restrict, int * __restrict); */ /* char*gcvt(double, int, int * __restrict, int * __restrict); */ -int grantpt(int); char *initstate(unsigned int, char *, size_t); longjrand48(unsigned short[3]); char *l64a(long); @@ -223,9 +222,6 @@ char*mktemp(char *); #endif longmrand48(void); longnrand48(unsigned short[3]); -int posix_openpt(int); -char *ptsname(int); -int ptsname_r(int, char *, size_t); int putenv(char *); longrandom(void); unsigned short @@ -233,8 +229,18 @@ unsigned short char *setstate(/* const */ char *); voidsrand48(long); voidsrandom(unsigned int); +#endif /* __XSI_VISIBLE */ + +#if __XSI_VISIBLE +int grantpt(int); +int posix_openpt(int); +char *ptsname(int); int unlockpt(int); #endif /* __XSI_VISIBLE */ +#if __BSD_VISIBLE +/* ptsname_r will be included in POSIX issue 8 */ +int ptsname_r(int, char *, size_t); +#endif #if __BSD_VISIBLE extern const char *malloc_conf; Modified: head/lib/libc/stdlib/Symbol.map == --- head/lib/libc/stdlib/Symbol.map Mon Oct 19 22:32:36 2020 (r366865) +++ head/lib/libc/stdlib/Symbol.map Tue Oct 20 01:29:45 2020 (r366866) @@ -122,10 +122,10 @@ FBSD_1.5 { }; FBSD_1.6 { + ptsname_r; qsort_s; rand; srand; - ptsname_r; }; FBSDprivate_1.0 { Modified: head/lib/libc/stdlib/ptsname.c == --- head/lib/libc/stdlib/ptsname.c Mon Oct 19 22:32:36 2020 (r366865) +++ head/lib/libc/stdlib/ptsname.c Tue Oct 20 01:29:45 2020 (r366866) @@ -76,7 +76,7 @@ __strong_reference(__isptmaster, unlockpt); * associated with the specified master. */ int -ptsname_r(int fildes, char *buffer, size_t buflen) +__ptsname_r(int fildes, char *buffer, size_t buflen) { if (buflen <= sizeof(_PATH_DEV)) { @@ -101,6 +101,8 @@ ptsname_r(int fildes, char *buffer, size_t buflen) return (0); } +__strong_reference(__ptsname_r, ptsname_r); + /* * ptsname(): return the pathname of the slave pseudo-terminal device * associated with the specified master. @@ -108,10 +110,10 @@ ptsname_r(int fildes, char *buffer, size_t buflen) char * ptsname(int fildes) { - static char pt_slave[sizeof _PATH_DEV + SPECNAMELEN]; + static char pt_slave[sizeof(_PATH_DEV) + SPECNAMELEN]; - if (ptsname_r(fildes, pt_slave, sizeof(pt_slave)) == 0) + if (__ptsname_r(fildes, pt_slave, sizeof(pt_slave)) == 0) return (pt_slave); - else - return (NULL); + + return (NULL); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366865 - head/sys/dev/ahci
Author: br Date: Mon Oct 19 22:32:36 2020 New Revision: 366865 URL: https://svnweb.freebsd.org/changeset/base/366865 Log: Fix build: only set iommu buswide flag if IOMMU code is included. Sponsored by: Innovate DSbD Modified: head/sys/dev/ahci/ahci_pci.c Modified: head/sys/dev/ahci/ahci_pci.c == --- head/sys/dev/ahci/ahci_pci.cMon Oct 19 22:27:21 2020 (r366864) +++ head/sys/dev/ahci/ahci_pci.cMon Oct 19 22:32:36 2020 (r366865) @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_iommu.h" + #include #include #include @@ -499,6 +501,7 @@ ahci_pci_attach(device_t dev) i++; ctlr->quirks = ahci_ids[i].quirks; +#ifdef IOMMU if (ctlr->quirks & AHCI_Q_IOMMU_BUSWIDE) { /* * The controller issues DMA requests from PCI function 1, @@ -507,6 +510,7 @@ ahci_pci_attach(device_t dev) */ bus_dma_iommu_set_buswide(dev); } +#endif /* Limit speed for my onboard JMicron external port. * It is not eSATA really, limit to SATA 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"
Re: svn commit: r366833 - in head/sys: dev/iommu kern sys
On Mon, Oct 19, 2020 at 03:08:32PM +0100, Jessica Clarke wrote: > On 19 Oct 2020, at 14:10, Ruslan Bukin wrote: > > > > +#ifndef _DEV_IOMMU_IOMMU_MSI_H_ > > +#define _DEV_IOMMU_IOMMU_MSI_H_ > > + > > +#include > > + > > +struct iommu_unit; > > This seems unused, perhaps left from a previous patch version? > The forward declaration is not needed here, indeed. Thanks. Ruslan ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366863 - head/sys/dev/ahci
Author: br Date: Mon Oct 19 21:27:27 2020 New Revision: 366863 URL: https://svnweb.freebsd.org/changeset/base/366863 Log: Add IOMMU_BUSWIDE ahci quirk. Some controllers use PCI function 1 as the requester ID for DMA transfers, but the controllers are not PCI multifunction. Set the iommu buswide flag for them. This should instruct an IOMMU driver to use the same translation rule for all the devices and functions of a bus. This was discovered on the ARM Neoverse N1 System Development Platform (ARM N1SDP). Bug reference: https://bugzilla.kernel.org/show_bug.cgi?id=42679 Reported by: andrew Reviewed by: kib, mav Sponsored by: Innovate DSbD Differential Revision:https://reviews.freebsd.org/D26857 Modified: head/sys/dev/ahci/ahci.h head/sys/dev/ahci/ahci_pci.c Modified: head/sys/dev/ahci/ahci.h == --- head/sys/dev/ahci/ahci.hMon Oct 19 21:11:49 2020(r366862) +++ head/sys/dev/ahci/ahci.hMon Oct 19 21:27:27 2020(r366863) @@ -624,6 +624,7 @@ enum ahci_err_type { #define AHCI_Q_MRVL_SR_DEL 0x0020 #define AHCI_Q_NOCCS 0x0040 #define AHCI_Q_NOAUX 0x0080 +#define AHCI_Q_IOMMU_BUSWIDE 0x0100 #define AHCI_Q_BIT_STRING \ "\020" \ @@ -650,7 +651,8 @@ enum ahci_err_type { "\025NOMSIX"\ "\026MRVL_SR_DEL" \ "\027NOCCS" \ - "\030NOAUX" + "\030NOAUX" \ + "\031IOMMU_BUSWIDE" int ahci_attach(device_t dev); int ahci_detach(device_t dev); Modified: head/sys/dev/ahci/ahci_pci.c == --- head/sys/dev/ahci/ahci_pci.cMon Oct 19 21:11:49 2020 (r366862) +++ head/sys/dev/ahci/ahci_pci.cMon Oct 19 21:27:27 2020 (r366863) @@ -37,12 +37,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include #include #include #include #include +#include #include "ahci.h" static int force_ahci = 1; @@ -248,7 +252,10 @@ static const struct { {0x2365197b, 0x00, "JMicron JMB365",AHCI_Q_NOFORCE}, {0x2366197b, 0x00, "JMicron JMB366",AHCI_Q_NOFORCE}, {0x2368197b, 0x00, "JMicron JMB368",AHCI_Q_NOFORCE}, + {0x2392197b, 0x00, "JMicron JMB388",AHCI_Q_IOMMU_BUSWIDE}, {0x0585197b, 0x00, "JMicron JMB58x",0}, + {0x01221c28, 0x00, "Lite-On Plextor M6E (Marvell 88SS9183)", + AHCI_Q_IOMMU_BUSWIDE}, {0x61ab, 0x00, "Marvell 88SE6111", AHCI_Q_NOFORCE | AHCI_Q_NOPMP | AHCI_Q_1CH | AHCI_Q_EDGEIS}, {0x612111ab, 0x00, "Marvell 88SE6121", AHCI_Q_NOFORCE | AHCI_Q_NOPMP | @@ -257,19 +264,28 @@ static const struct { AHCI_Q_4CH | AHCI_Q_EDGEIS | AHCI_Q_NONCQ | AHCI_Q_NOCOUNT}, {0x614511ab, 0x00, "Marvell 88SE6145", AHCI_Q_NOFORCE | AHCI_Q_NOPMP | AHCI_Q_4CH | AHCI_Q_EDGEIS | AHCI_Q_NONCQ | AHCI_Q_NOCOUNT}, - {0x91201b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS}, - {0x91231b4b, 0x11, "Marvell 88SE912x", AHCI_Q_ALTSIG}, - {0x91231b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_SATA2}, + {0x91201b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS | + AHCI_Q_IOMMU_BUSWIDE}, + {0x91231b4b, 0x11, "Marvell 88SE912x", AHCI_Q_ALTSIG | + AHCI_Q_IOMMU_BUSWIDE}, + {0x91231b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS | AHCI_Q_SATA2 | + AHCI_Q_IOMMU_BUSWIDE}, {0x91251b4b, 0x00, "Marvell 88SE9125", 0}, - {0x91281b4b, 0x00, "Marvell 88SE9128", AHCI_Q_ALTSIG}, - {0x91301b4b, 0x00, "Marvell 88SE9130", AHCI_Q_ALTSIG}, - {0x91721b4b, 0x00, "Marvell 88SE9172", 0}, - {0x91821b4b, 0x00, "Marvell 88SE9182", 0}, - {0x91831b4b, 0x00, "Marvell 88SS9183", 0}, - {0x91a01b4b, 0x00, "Marvell 88SE91Ax", 0}, + {0x91281b4b, 0x00, "Marvell 88SE9128", AHCI_Q_ALTSIG | + AHCI_Q_IOMMU_BUSWIDE}, + {0x91301b4b, 0x00, "Marvell 88SE9130", AHCI_Q_ALTSIG | + AHCI_Q_IOMMU_BUSWIDE}, + {0x91701b4b, 0x00, "Marvell 88SE9170", AHCI_Q_IOMMU_BUSWIDE}, + {0x91721b4b, 0x00, "Marvell 88SE9172", AHCI_Q_IOMMU_BUSWIDE}, + {0x917a1b4b, 0x00, "Marvell 88SE917A", AHCI_Q_IOMMU_BUSWIDE}, + {0x91821b4b, 0x00, "Marvell 88SE9182", AHCI_Q_IOMMU_BUSWIDE}, + {0x91831b4b, 0x00, "Marvell 88SS9183", AHCI_Q_IOMMU_BUSWIDE}, + {0x91a01b4b, 0x00, "Marvell 88SE91Ax", AHCI_Q_IOMMU_BUSWIDE}, {0x92151b4b, 0x00, "Marvell 88SE9215", 0}, - {0x92201b4b, 0x00, "Marvell 88SE9220", AHCI_Q_ALTSIG}, - {0x92301b4b, 0x00, "Marvell 88SE9230", AHCI_Q_ALTSIG}, + {0x92201b4b, 0x00, "Marvell 88SE9220", AHCI_Q_ALTSIG | + AHCI_Q_IOMMU_BUSWIDE}, + {0x92301b4b, 0x00, "Marvell 88SE9230", AHCI_Q_ALTSIG | +
svn commit: r366862 - in head: share/man/man4 sys/dev/cxgbe
Author: np Date: Mon Oct 19 21:11:49 2020 New Revision: 366862 URL: https://svnweb.freebsd.org/changeset/base/366862 Log: cxgbe(4): Updates to the drop features from r366532. MFC after:1 week Sponsored by: Chelsio Communications Modified: head/share/man/man4/cxgbe.4 head/sys/dev/cxgbe/t4_main.c Modified: head/share/man/man4/cxgbe.4 == --- head/share/man/man4/cxgbe.4 Mon Oct 19 20:43:29 2020(r366861) +++ head/share/man/man4/cxgbe.4 Mon Oct 19 21:11:49 2020(r366862) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 8, 2020 +.Dd October 19, 2020 .Dt CXGBE 4 .Os .Sh NAME @@ -369,6 +369,7 @@ The attack filter will drop an incoming frame if any o true: src ip/ip6 == dst ip/ip6; tcp and src/dst ip is not unicast; src/dst ip is loopback (127.x.y.z); src ip6 is not unicast; src/dst ip6 is loopback (::1/128) or unspecified (::/128); tcp and src/dst ip6 is mcast (ff00::/8). +This facility is available on T4 and T5 based cards only. .It Va hw.cxgbe.drop_ip_fragments Set to 1 to drop all incoming IP fragments. Default is 0. @@ -378,9 +379,11 @@ Set to 1 to drop incoming frames with Layer 2 length o Default is 1. .It Va hw.cxgbe.drop_pkts_with_l3_errors Set to 1 to drop incoming frames with IP version, length, or checksum errors. +The IP checksum is validated for TCP or UDP packets only. Default is 0. .It Va hw.cxgbe.drop_pkts_with_l4_errors -Set to 1 to drop incoming frames with Layer 4 length, checksum, or other errors. +Set to 1 to drop incoming frames with Layer 4 (TCP or UDP) length, +checksum, or other errors. Default is 0. .El .Sh SUPPORT Modified: head/sys/dev/cxgbe/t4_main.c == --- head/sys/dev/cxgbe/t4_main.cMon Oct 19 20:43:29 2020 (r366861) +++ head/sys/dev/cxgbe/t4_main.cMon Oct 19 21:11:49 2020 (r366862) @@ -4823,7 +4823,7 @@ set_params__post_init(struct adapter *sc) F_DROPERRORIPHDRLEN | F_DROPERRORTCPHDRLEN | F_DROPERRORPKTLEN | F_DROPERRORTCPOPT | F_DROPERRORCSUMIP | F_DROPERRORCSUM; val = 0; - if (t4_attack_filter != 0) { + if (chip_id(sc) < CHELSIO_T6 && t4_attack_filter != 0) { t4_set_reg_field(sc, A_TP_GLOBAL_CONFIG, F_ATTACKFILTERENABLE, F_ATTACKFILTERENABLE); val |= F_DROPERRORATTACK; ___ 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: r366861 - in head/sys/modules: . vmware
Author: emaste Date: Mon Oct 19 20:43:29 2020 New Revision: 366861 URL: https://svnweb.freebsd.org/changeset/base/366861 Log: build vmware modules on arm64 pvscsi and vmxnet3 build and work. Exclude vmci for now as it contains x86-specific assembly. Reported by: Vincent Milum Jr MFC after:2 weeks Sponsored by: The FreeBSD Foundation Modified: head/sys/modules/Makefile head/sys/modules/vmware/Makefile Modified: head/sys/modules/Makefile == --- head/sys/modules/Makefile Mon Oct 19 20:42:01 2020(r366860) +++ head/sys/modules/Makefile Mon Oct 19 20:43:29 2020(r366861) @@ -511,6 +511,7 @@ _mthca= mthca _mlx4ib= mlx4ib _mlx5ib= mlx5ib .endif +_vmware= vmware .endif .if ${MK_NETGRAPH} != "no" || defined(ALL_MODULES) @@ -633,7 +634,6 @@ _safe= safe _speaker= speaker _splash= splash _sppp= sppp -_vmware= vmware _wbwd= wbwd _wi= wi Modified: head/sys/modules/vmware/Makefile == --- head/sys/modules/vmware/MakefileMon Oct 19 20:42:01 2020 (r366860) +++ head/sys/modules/vmware/MakefileMon Oct 19 20:43:29 2020 (r366861) @@ -23,6 +23,8 @@ # SUCH DAMAGE. # -SUBDIR= pvscsi vmci vmxnet3 - +SUBDIR= pvscsi vmxnet3 +.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" +SUBDIR+= vmci +.endif .include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366857 - head/libexec/rc/rc.d
Author: cy Date: Mon Oct 19 20:37:38 2020 New Revision: 366857 URL: https://svnweb.freebsd.org/changeset/base/366857 Log: Destroy cloned interfaces at netif stop, netif restart and shutdown. This is especially important during shutdown because a child interface of lagg with WOL enabled will not enable WOL at interface shutdown and thus no WOL to wake up the device (and machine). PR: 158734, 109980 Reported by: Antonio Huete Jimenez Marat N.Afanasyev reviewed by: kp MFC after:1 week Differential Revision:https://reviews.freebsd.org/D26797 Modified: head/libexec/rc/rc.d/netif Modified: head/libexec/rc/rc.d/netif == --- head/libexec/rc/rc.d/netif Mon Oct 19 20:37:04 2020(r366856) +++ head/libexec/rc/rc.d/netif Mon Oct 19 20:37:38 2020(r366857) @@ -28,7 +28,7 @@ # PROVIDE: netif # REQUIRE: FILESYSTEMS iovctl serial sppp sysctl # REQUIRE: hostid ipfs -# KEYWORD: nojailvnet +# KEYWORD: nojailvnet shutdown . /etc/rc.subr . /etc/network.subr ___ 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: r366855 - in head/sys/geom: . uzip
Author: trasz Date: Mon Oct 19 20:26:37 2020 New Revision: 366855 URL: https://svnweb.freebsd.org/changeset/base/366855 Log: Fix fallout from r366811. PR: 250442 Reported by: lwhsu Reviewed by: mav MFC after:2 weeks Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision:https://reviews.freebsd.org/D26855 Modified: head/sys/geom/geom_dev.c head/sys/geom/uzip/g_uzip.c Modified: head/sys/geom/geom_dev.c == --- head/sys/geom/geom_dev.cMon Oct 19 20:08:50 2020(r366854) +++ head/sys/geom/geom_dev.cMon Oct 19 20:26:37 2020(r366855) @@ -346,9 +346,15 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, cp->private = sc; cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; error = g_attach(cp, pp); - KASSERT(error == 0 || error == ENXIO, - ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error)); - + if (error != 0) { + printf("%s: g_dev_taste(%s) failed to g_attach, error=%d\n", + __func__, pp->name, error); + g_destroy_consumer(cp); + g_destroy_geom(gp); + mtx_destroy(>sc_mtx); + g_free(sc); + return (NULL); + } make_dev_args_init(); args.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; args.mda_devsw = _dev_cdevsw; Modified: head/sys/geom/uzip/g_uzip.c == --- head/sys/geom/uzip/g_uzip.c Mon Oct 19 20:08:50 2020(r366854) +++ head/sys/geom/uzip/g_uzip.c Mon Oct 19 20:26:37 2020(r366855) @@ -707,11 +707,11 @@ g_uzip_taste(struct g_class *mp, struct g_provider *pp gp = g_new_geomf(mp, GUZ_DEV_NAME("%s"), pp->name); cp = g_new_consumer(gp); error = g_attach(cp, pp); - if (error == 0) - error = g_access(cp, 1, 0, 0); - if (error) { + if (error != 0) + goto e0; + error = g_access(cp, 1, 0, 0); + if (error) goto e1; - } g_topology_unlock(); /* @@ -942,6 +942,7 @@ e2: g_access(cp, -1, 0, 0); e1: g_detach(cp); +e0: g_destroy_consumer(cp); g_destroy_geom(gp); ___ 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: r366854 - head/sys/dev/cxgbe/tom
Author: jhb Date: Mon Oct 19 20:08:50 2020 New Revision: 366854 URL: https://svnweb.freebsd.org/changeset/base/366854 Log: Re-enable receive flow control for TOE TLS sockets. Flow control was disabled during initial TOE TLS development to workaround a hang (and to match the Linux TOE TLS support for T6). The rest of the TOE TLS code maintained credits as if flow control was enabled which was inherited from before the workaround was added with the exception that the receive window was allowed to go negative. This negative receive window handling (rcv_over) was because I hadn't realized the full implications of disabling flow control. To clean this up, re-enable flow control on TOE TLS sockets. The existing TPF_FORCE_CREDITS workaround is sufficient for the original hang. Now that flow control is enabled, remove the rcv_over workaround and instead assert that the receive window never goes negative matching plain TCP TOE sockets. Reviewed by: np MFC after:2 weeks Sponsored by: Chelsio Communications Differential Revision:https://reviews.freebsd.org/D26799 Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c head/sys/dev/cxgbe/tom/t4_tls.c head/sys/dev/cxgbe/tom/t4_tls.h head/sys/dev/cxgbe/tom/t4_tom.c Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c == --- head/sys/dev/cxgbe/tom/t4_cpl_io.c Mon Oct 19 20:08:47 2020 (r366853) +++ head/sys/dev/cxgbe/tom/t4_cpl_io.c Mon Oct 19 20:08:50 2020 (r366854) @@ -446,16 +446,6 @@ t4_rcvd_locked(struct toedev *tod, struct tcpcb *tp) SOCKBUF_LOCK_ASSERT(sb); rx_credits = sbspace(sb) > tp->rcv_wnd ? sbspace(sb) - tp->rcv_wnd : 0; - if (ulp_mode(toep) == ULP_MODE_TLS) { - if (toep->tls.rcv_over >= rx_credits) { - toep->tls.rcv_over -= rx_credits; - rx_credits = 0; - } else { - rx_credits -= toep->tls.rcv_over; - toep->tls.rcv_over = 0; - } - } - if (rx_credits > 0 && (tp->rcv_wnd <= 32 * 1024 || rx_credits >= 64 * 1024 || (rx_credits >= 16 * 1024 && tp->rcv_wnd <= 128 * 1024) || Modified: head/sys/dev/cxgbe/tom/t4_tls.c == --- head/sys/dev/cxgbe/tom/t4_tls.c Mon Oct 19 20:08:47 2020 (r366853) +++ head/sys/dev/cxgbe/tom/t4_tls.c Mon Oct 19 20:08:50 2020 (r366854) @@ -2045,11 +2045,9 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_head #endif tp->rcv_nxt += pdu_length; - if (tp->rcv_wnd < pdu_length) { - toep->tls.rcv_over += pdu_length - tp->rcv_wnd; - tp->rcv_wnd = 0; - } else - tp->rcv_wnd -= pdu_length; + KASSERT(tp->rcv_wnd >= pdu_length, + ("%s: negative window size", __func__)); + tp->rcv_wnd -= pdu_length; /* XXX: Not sure what to do about urgent data. */ Modified: head/sys/dev/cxgbe/tom/t4_tls.h == --- head/sys/dev/cxgbe/tom/t4_tls.h Mon Oct 19 20:08:47 2020 (r366853) +++ head/sys/dev/cxgbe/tom/t4_tls.h Mon Oct 19 20:08:50 2020 (r366854) @@ -276,7 +276,6 @@ struct tls_ofld_info { enum tls_mode mode; struct callout handshake_timer; u_int sb_off; - u_int rcv_over; }; struct tls_key_req { Modified: head/sys/dev/cxgbe/tom/t4_tom.c == --- head/sys/dev/cxgbe/tom/t4_tom.c Mon Oct 19 20:08:47 2020 (r366853) +++ head/sys/dev/cxgbe/tom/t4_tom.c Mon Oct 19 20:08:50 2020 (r366854) @@ -1036,8 +1036,6 @@ calc_options2(struct vi_info *vi, struct conn_params * if (cp->ulp_mode == ULP_MODE_TCPDDP) opt2 |= F_RX_FC_DDP; #endif - if (cp->ulp_mode == ULP_MODE_TLS) - opt2 |= F_RX_FC_DISABLE; return (htobe32(opt2)); } ___ 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: r366853 - head/sys/dev/cxgbe/common
Author: np Date: Mon Oct 19 20:08:47 2020 New Revision: 366853 URL: https://svnweb.freebsd.org/changeset/base/366853 Log: cxgbe(4): Fix page fault in t4_get_lb_stats with 2 port T5 cards. PR: 250449 Reported by: freqlabs@ MFC after:1 week Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/common/t4_hw.c Modified: head/sys/dev/cxgbe/common/t4_hw.c == --- head/sys/dev/cxgbe/common/t4_hw.c Mon Oct 19 20:04:03 2020 (r366852) +++ head/sys/dev/cxgbe/common/t4_hw.c Mon Oct 19 20:08:47 2020 (r366853) @@ -6957,7 +6957,6 @@ void t4_get_port_stats(struct adapter *adap, int idx, */ void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p) { - u32 bgmap = adap2pinfo(adap, idx)->mps_bg_map; #define GET_STAT(name) \ t4_read_reg64(adap, \ @@ -6982,14 +6981,18 @@ void t4_get_lb_stats(struct adapter *adap, int idx, st p->frames_1519_max = GET_STAT(1519B_MAX); p->drop = GET_STAT(DROP_FRAMES); - p->ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0; - p->ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0; - p->ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0; - p->ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0; - p->trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0; - p->trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0; - p->trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0; - p->trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0; + if (idx < adap->params.nports) { + u32 bg = adap2pinfo(adap, idx)->mps_bg_map; + + p->ovflow0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0; + p->ovflow1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0; + p->ovflow2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0; + p->ovflow3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0; + p->trunc0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0; + p->trunc1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0; + p->trunc2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0; + p->trunc3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0; + } #undef GET_STAT #undef GET_STAT_COM ___ 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: r366852 - head/sys/opencrypto
Author: jhb Date: Mon Oct 19 20:04:03 2020 New Revision: 366852 URL: https://svnweb.freebsd.org/changeset/base/366852 Log: Fix a couple of bugs for asym crypto introduced in r359374. - Check for null pointers in the crypto_drivers[] array when checking for empty slots in crypto_select_kdriver(). - Handle the case where crypto_kdone() is invoked on a request where krq_cap is NULL due to not finding a matching driver. Reviewed by: markj Sponsored by: Chelsio Communications Differential Revision:https://reviews.freebsd.org/D26811 Modified: head/sys/opencrypto/crypto.c Modified: head/sys/opencrypto/crypto.c == --- head/sys/opencrypto/crypto.cMon Oct 19 19:51:03 2020 (r366851) +++ head/sys/opencrypto/crypto.cMon Oct 19 20:04:03 2020 (r366852) @@ -1540,7 +1540,7 @@ again: * match), then skip. */ cap = crypto_drivers[hid]; - if (cap->cc_dev == NULL || + if (cap == NULL || (cap->cc_flags & match) == 0) continue; @@ -1880,15 +1880,18 @@ crypto_kdone(struct cryptkop *krp) if (krp->krp_status != 0) CRYPTOSTAT_INC(cs_kerrs); - CRYPTO_DRIVER_LOCK(); cap = krp->krp_cap; - KASSERT(cap->cc_koperations > 0, ("cc_koperations == 0")); - cap->cc_koperations--; - if (cap->cc_koperations == 0 && cap->cc_flags & CRYPTOCAP_F_CLEANUP) - wakeup(cap); - CRYPTO_DRIVER_UNLOCK(); - krp->krp_cap = NULL; - cap_rele(cap); + if (cap != NULL) { + CRYPTO_DRIVER_LOCK(); + KASSERT(cap->cc_koperations > 0, ("cc_koperations == 0")); + cap->cc_koperations--; + if (cap->cc_koperations == 0 && + cap->cc_flags & CRYPTOCAP_F_CLEANUP) + wakeup(cap); + CRYPTO_DRIVER_UNLOCK(); + krp->krp_cap = NULL; + cap_rele(cap); + } ret_worker = CRYPTO_RETW(0); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366850 - in head/lib/googletest: gmock gmock/tests gmock_main gmock_main/tests gtest gtest/tests gtest_main gtest_main/tests tests tests/gmock tests/gmock_main tests/gtest tests/gtest_...
Author: arichardson Date: Mon Oct 19 19:50:57 2020 New Revision: 366850 URL: https://svnweb.freebsd.org/changeset/base/366850 Log: Major improvement to build parallelism for googletest internal tests Currently the googletest internal tests build after the matching library. However, each of these is serialized at the top level makefile. Additionally some of the tests (e.g. the gmock-matches-test) take up to 90 seconds to build with clang -O2. Having to wait for this test to complete before continuing to the next directory seriously slows down the parllelism of a -j32 build. Before this change running `make -C lib/googletest -j32 -s` in buildenv took 202 seconds, now it's 153 due to improved parallelism. Reviewed By: emaste (no objection) Differential Revision: https://reviews.freebsd.org/D26748 Added: head/lib/googletest/tests/Makefile.inc (contents, props changed) head/lib/googletest/tests/gmock/ head/lib/googletest/tests/gmock/Makefile (contents, props changed) - copied, changed from r366849, head/lib/googletest/gmock/tests/Makefile head/lib/googletest/tests/gmock_main/ head/lib/googletest/tests/gmock_main/Makefile (contents, props changed) - copied, changed from r366849, head/lib/googletest/gmock_main/tests/Makefile head/lib/googletest/tests/gtest/ head/lib/googletest/tests/gtest/Makefile (contents, props changed) - copied, changed from r366849, head/lib/googletest/gtest/tests/Makefile head/lib/googletest/tests/gtest_main/ head/lib/googletest/tests/gtest_main/Makefile (contents, props changed) - copied, changed from r366849, head/lib/googletest/gtest_main/tests/Makefile Deleted: head/lib/googletest/gmock/tests/Makefile head/lib/googletest/gmock_main/tests/Makefile head/lib/googletest/gtest/tests/Makefile head/lib/googletest/gtest_main/tests/Makefile Modified: head/lib/googletest/gmock/Makefile head/lib/googletest/gmock_main/Makefile head/lib/googletest/gtest/Makefile head/lib/googletest/gtest_main/Makefile head/lib/googletest/tests/Makefile Modified: head/lib/googletest/gmock/Makefile == --- head/lib/googletest/gmock/Makefile Mon Oct 19 19:23:22 2020 (r366849) +++ head/lib/googletest/gmock/Makefile Mon Oct 19 19:50:57 2020 (r366850) @@ -42,7 +42,4 @@ INTERNAL_CUSTOM_INCS+=gmock/internal/custom/gmock-gen SRCS+= gmock-all.cc -HAS_TESTS= -SUBDIR.${MK_TESTS}+= tests - .include Modified: head/lib/googletest/gmock_main/Makefile == --- head/lib/googletest/gmock_main/Makefile Mon Oct 19 19:23:22 2020 (r366849) +++ head/lib/googletest/gmock_main/Makefile Mon Oct 19 19:50:57 2020 (r366850) @@ -19,7 +19,4 @@ LDFLAGS+= -L${LIBGMOCKDIR} SRCS+= gmock_main.cc -HAS_TESTS= -SUBDIR.${MK_TESTS}+= tests - .include Modified: head/lib/googletest/gtest/Makefile == --- head/lib/googletest/gtest/Makefile Mon Oct 19 19:23:22 2020 (r366849) +++ head/lib/googletest/gtest/Makefile Mon Oct 19 19:50:57 2020 (r366850) @@ -47,7 +47,4 @@ SRCS+=gtest-all.cc LIBADD+= pthread regex -HAS_TESTS= -SUBDIR.${MK_TESTS}+= tests - .include Modified: head/lib/googletest/gtest_main/Makefile == --- head/lib/googletest/gtest_main/Makefile Mon Oct 19 19:23:22 2020 (r366849) +++ head/lib/googletest/gtest_main/Makefile Mon Oct 19 19:50:57 2020 (r366850) @@ -17,7 +17,4 @@ LDFLAGS+= -L${LIBGTESTDIR} SRCS+= gtest_main.cc -HAS_TESTS= -SUBDIR.${MK_TESTS}+= tests - .include Modified: head/lib/googletest/tests/Makefile == --- head/lib/googletest/tests/Makefile Mon Oct 19 19:23:22 2020 (r366849) +++ head/lib/googletest/tests/Makefile Mon Oct 19 19:50:57 2020 (r366850) @@ -3,4 +3,10 @@ .PATH: ${SRCTOP}/tests KYUAFILE= yes +# Note: we start the gmock_main and gmock tests first since those take up to +# 60 seconds to build, so starting them late seriously reduces build parallism. +SUBDIR=gmock_main gmock gtest_main gtest + +SUBDIR_PARALLEL= + .include Added: head/lib/googletest/tests/Makefile.inc == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/googletest/tests/Makefile.inc Mon Oct 19 19:50:57 2020 (r366850) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +.include "../Makefile.inc" +# Keep the existing tests directory structure (with subdirs per component) +# rather than installing all of them to /usr/tests/lib/googletest +TESTSDIR=
svn commit: r366851 - head/lib/googletest
Author: arichardson Date: Mon Oct 19 19:51:03 2020 New Revision: 366851 URL: https://svnweb.freebsd.org/changeset/base/366851 Log: Enable SUBDIR_PARALLEL for lib/googletest This saves a few seconds in a parallel build since we can build the gtest_main and gmock subdirectories in parallel. Reviewed By: ngie Differential Revision: https://reviews.freebsd.org/D26760 Modified: head/lib/googletest/Makefile Modified: head/lib/googletest/Makefile == --- head/lib/googletest/MakefileMon Oct 19 19:50:57 2020 (r366850) +++ head/lib/googletest/MakefileMon Oct 19 19:51:03 2020 (r366851) @@ -3,12 +3,16 @@ .include SUBDIR+= gtest -SUBDIR+= .WAIT SUBDIR+= gmock -SUBDIR+= .WAIT SUBDIR+= gmock_main SUBDIR+= gtest_main SUBDIR.${MK_TESTS}+= tests + +SUBDIR_DEPEND_gtest_main= gtest +SUBDIR_DEPEND_gmock= gtest +SUBDIR_DEPEND_gmock_main= gmock +SUBDIR_DEPEND_tests= gmock_main +SUBDIR_PARALLEL= .include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366849 - head/sys/fs/nullfs
Author: kib Date: Mon Oct 19 19:23:22 2020 New Revision: 366849 URL: https://svnweb.freebsd.org/changeset/base/366849 Log: nullfs: ensure correct lock is taken after bypass. If lower VOP relocked the lower vnode, it is possible that nullfs vnode was reclaimed meantime. In this case nullfs vnode no longer shares lock with lower vnode, which breaks locking protocol. Check for the condition and acquire nullfs vnode lock if detected. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after:1 week Modified: head/sys/fs/nullfs/null_vnops.c Modified: head/sys/fs/nullfs/null_vnops.c == --- head/sys/fs/nullfs/null_vnops.c Mon Oct 19 19:20:23 2020 (r366848) +++ head/sys/fs/nullfs/null_vnops.c Mon Oct 19 19:23:22 2020 (r366849) @@ -227,6 +227,7 @@ null_bypass(struct vop_generic_args *ap) struct vnode *old_vps[VDESC_MAX_VPS]; struct vnode **vps_p[VDESC_MAX_VPS]; struct vnode ***vppp; + struct vnode *lvp; struct vnodeop_desc *descp = ap->a_desc; int reles, i; @@ -295,6 +296,23 @@ null_bypass(struct vop_generic_args *ap) if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET) break; /* bail out at end of list */ if (old_vps[i]) { + lvp = *(vps_p[i]); + + /* +* If lowervp was unlocked during VOP +* operation, nullfs upper vnode could have +* been reclaimed, which changes its v_vnlock +* back to private v_lock. In this case we +* must move lock ownership from lower to +* upper (reclaimed) vnode. +*/ + if (lvp != NULLVP && + VOP_ISLOCKED(lvp) == LK_EXCLUSIVE && + old_vps[i]->v_vnlock != lvp->v_vnlock) { + VOP_UNLOCK(lvp); + VOP_LOCK(old_vps[i], LK_EXCLUSIVE | LK_RETRY); + } + *(vps_p[i]) = old_vps[i]; #if 0 if (reles & VDESC_VP0_WILLUNLOCK) ___ 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: r366848 - head/sys/kern
Author: kib Date: Mon Oct 19 19:20:23 2020 New Revision: 366848 URL: https://svnweb.freebsd.org/changeset/base/366848 Log: vgonel(): avoid recursing into VOP_INACTIVE(). It is a common pattern for filesystems' VOP_INACTIVE() implementation to forcibly reclaim the vnode when its state is final. For instance, UFS vnode with zero link count is removed, and since it is inactivated, the last open reference on it is dropped. On the other hand, vnode might get spurious usecount reference for many reasons. If the spurious reference exists while vgonel() checks for active state of the vnode, it would recurse into VOP_INACTIVE(). Fix it by checking and not doing inactivation when vgone() was called from inactive VOP. Reported and tested by: pho Discussed with: mjg Sponsored by: The FreeBSD Foundation MFC after:1 week Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c == --- head/sys/kern/vfs_subr.cMon Oct 19 18:54:44 2020(r366847) +++ head/sys/kern/vfs_subr.cMon Oct 19 19:20:23 2020(r366848) @@ -1794,6 +1794,8 @@ freevnode(struct vnode *vp) VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for ..")); VNASSERT(TAILQ_EMPTY(>v_rl.rl_waiters), vp, ("Dangling rangelock waiters")); + VNASSERT((vp->v_iflag & (VI_DOINGINACT | VI_OWEINACT)) == 0, vp, + ("Leaked inactivation")); VI_UNLOCK(vp); #ifdef MAC mac_vnode_destroy(vp); @@ -3803,7 +3805,7 @@ vgonel(struct vnode *vp) struct thread *td; struct mount *mp; vm_object_t object; - bool active, oweinact; + bool active, doinginact, oweinact; ASSERT_VOP_ELOCKED(vp, "vgonel"); ASSERT_VI_LOCKED(vp, "vgonel"); @@ -3825,11 +3827,17 @@ vgonel(struct vnode *vp) vp->v_irflag |= VIRF_DOOMED; /* -* Check to see if the vnode is in use. If so, we have to call -* VOP_CLOSE() and VOP_INACTIVE(). +* Check to see if the vnode is in use. If so, we have to +* call VOP_CLOSE() and VOP_INACTIVE(). +* +* It could be that VOP_INACTIVE() requested reclamation, in +* which case we should avoid recursion, so check +* VI_DOINGINACT. This is not precise but good enough. */ active = vp->v_usecount > 0; oweinact = (vp->v_iflag & VI_OWEINACT) != 0; + doinginact = (vp->v_iflag & VI_DOINGINACT) != 0; + /* * If we need to do inactive VI_OWEINACT will be set. */ @@ -3850,7 +3858,7 @@ vgonel(struct vnode *vp) */ if (active) VOP_CLOSE(vp, FNONBLOCK, NOCRED, td); - if (oweinact || active) { + if ((oweinact || active) && !doinginact) { VI_LOCK(vp); vinactivef(vp); VI_UNLOCK(vp); ___ 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: r366847 - head/sys/vm
Author: emaste Date: Mon Oct 19 18:54:44 2020 New Revision: 366847 URL: https://svnweb.freebsd.org/changeset/base/366847 Log: uma: fix KTR message after r366840 Reported by: bz Sponsored by: The FreeBSD Foundation Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Mon Oct 19 18:51:51 2020(r366846) +++ head/sys/vm/uma_core.c Mon Oct 19 18:54:44 2020(r366847) @@ -1427,7 +1427,7 @@ keg_drain_domain(uma_keg_t keg, int domain) LIST_INIT(); CTR4(KTR_UMA, "keg_drain %s(%p) domain %d free items: %u", - keg->uk_name, keg, i, dom->ud_free_items); + keg->uk_name, keg, domain, dom->ud_free_items); KEG_LOCK(keg, domain); ___ 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: r366846 - head/sys/kern
Author: mjg Date: Mon Oct 19 18:51:51 2020 New Revision: 366846 URL: https://svnweb.freebsd.org/changeset/base/366846 Log: cache: promote negative entries based on more than one hit During tinderbox and similar workloads negative entries get at least one hit before they get evicted. In the current scheme this avoidably promotes them. Be conservative and stick to 2 hits for now. Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c == --- head/sys/kern/vfs_cache.c Mon Oct 19 18:24:06 2020(r366845) +++ head/sys/kern/vfs_cache.c Mon Oct 19 18:51:51 2020(r366846) @@ -129,6 +129,7 @@ SDT_PROBE_DECLARE(vfs, namei, lookup, return); */ struct negstate { u_char neg_flag; + u_char neg_hit; }; _Static_assert(sizeof(struct negstate) <= sizeof(struct vnode *), "the state must fit in a union with a pointer without growing it"); @@ -905,18 +906,27 @@ cache_neg_init(struct namecache *ncp) ncp->nc_flag |= NCF_NEGATIVE; ns = NCP2NEGSTATE(ncp); ns->neg_flag = 0; + ns->neg_hit = 0; counter_u64_add(neg_created, 1); } +#define CACHE_NEG_PROMOTION_THRESH 2 + static bool cache_neg_hit_prep(struct namecache *ncp) { struct negstate *ns; + u_char n; ns = NCP2NEGSTATE(ncp); - if ((ns->neg_flag & NEG_HOT) != 0) - return (true); - return (false); + n = atomic_load_char(>neg_hit); + for (;;) { + if (n >= CACHE_NEG_PROMOTION_THRESH) + return (false); + if (atomic_fcmpset_8(>neg_hit, , n + 1)) + break; + } + return (n + 1 == CACHE_NEG_PROMOTION_THRESH); } /* @@ -971,6 +981,7 @@ cache_neg_demote_locked(struct namecache *ncp) TAILQ_INSERT_TAIL(>nl_list, ncp, nc_dst); nl->nl_hotnum--; ns->neg_flag &= ~NEG_HOT; + atomic_store_char(>neg_hit, 0); } /* @@ -1098,7 +1109,7 @@ cache_neg_remove(struct namecache *ncp) } static struct neglist * -cache_neg_evict_select(void) +cache_neg_evict_select_list(void) { struct neglist *nl; u_int c; @@ -1112,6 +1123,33 @@ cache_neg_evict_select(void) return (nl); } +static struct namecache * +cache_neg_evict_select_entry(struct neglist *nl) +{ + struct namecache *ncp, *lncp; + struct negstate *ns, *lns; + int i; + + mtx_assert(>nl_evict_lock, MA_OWNED); + mtx_assert(>nl_lock, MA_OWNED); + ncp = TAILQ_FIRST(>nl_list); + if (ncp == NULL) + return (NULL); + lncp = ncp; + lns = NCP2NEGSTATE(lncp); + for (i = 1; i < 4; i++) { + ncp = TAILQ_NEXT(ncp, nc_dst); + if (ncp == NULL) + break; + ns = NCP2NEGSTATE(ncp); + if (ns->neg_hit < lns->neg_hit) { + lncp = ncp; + lns = ns; + } + } + return (lncp); +} + static bool cache_neg_evict(void) { @@ -1125,7 +1163,7 @@ cache_neg_evict(void) u_char nlen; bool evicted; - nl = cache_neg_evict_select(); + nl = cache_neg_evict_select_list(); if (nl == NULL) { return (false); } @@ -1135,7 +1173,7 @@ cache_neg_evict(void) if (ncp != NULL) { cache_neg_demote_locked(ncp); } - ncp = TAILQ_FIRST(>nl_list); + ncp = cache_neg_evict_select_entry(nl); if (ncp == NULL) { counter_u64_add(neg_evict_skipped_empty, 1); mtx_unlock(>nl_lock); ___ 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: r366845 - head/sys/kern
Author: jhb Date: Mon Oct 19 18:24:06 2020 New Revision: 366845 URL: https://svnweb.freebsd.org/changeset/base/366845 Log: Check TF_TOE not the tod pointer to determine if TOE is active. The TF_TOE flag is the check used in the rest of the network stack to determine if TOE is active on a socket. There is at least one path in the cxgbe(4) TOE driver that can leave the tod pointer non-NULL on a socket not using TOE. Reported by: Sony Arpita Das Reviewed by: np Sponsored by: Chelsio Communications Differential Revision:https://reviews.freebsd.org/D26803 Modified: head/sys/kern/uipc_ktls.c Modified: head/sys/kern/uipc_ktls.c == --- head/sys/kern/uipc_ktls.c Mon Oct 19 18:21:41 2020(r366844) +++ head/sys/kern/uipc_ktls.c Mon Oct 19 18:24:06 2020(r366845) @@ -734,7 +734,7 @@ ktls_try_toe(struct socket *so, struct ktls_session *t return (ECONNRESET); } tp = intotcpcb(inp); - if (tp->tod == NULL) { + if (!(tp->t_flags & TF_TOE)) { INP_WUNLOCK(inp); return (EOPNOTSUPP); } ___ 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: r366844 - in head: share/man/man4 sys/opencrypto
Author: jhb Date: Mon Oct 19 18:21:41 2020 New Revision: 366844 URL: https://svnweb.freebsd.org/changeset/base/366844 Log: Mark asymmetric cryptography via OCF deprecated for 14.0. Only one MIPS-specific driver implements support for one of the asymmetric operations. There are no in-kernel users besides /dev/crypto. The only known user of the /dev/crypto interface was the engine in OpenSSL releases before 1.1.0. 1.1.0 includes a rewritten engine that does not use the asymmetric operations due to lack of documentation. Reviewed by: cem, markj MFC after:1 week Sponsored by: Chelsio Communications Differential Revision:https://reviews.freebsd.org/D26810 Modified: head/share/man/man4/crypto.4 head/sys/opencrypto/crypto.c head/sys/opencrypto/cryptodev.c Modified: head/share/man/man4/crypto.4 == --- head/share/man/man4/crypto.4Mon Oct 19 17:35:45 2020 (r366843) +++ head/share/man/man4/crypto.4Mon Oct 19 18:21:41 2020 (r366844) @@ -60,7 +60,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2020 +.Dd October 19, 2020 .Dt CRYPTO 4 .Os .Sh NAME @@ -108,6 +108,11 @@ both asymmetric-key (public-key/private-key) requests modular arithmetic (for Diffie-Hellman key exchange and other cryptographic protocols). The two modes are described separately below. +.Sh DEPRECATION NOTICE +The asymmetric-key operations supported by this interface will not be +present in +.Fx 14.0 +and later. .Sh THEORY OF OPERATION Regardless of whether symmetric-key or asymmetric-key operations are to be performed, use of the device requires a basic series of steps: Modified: head/sys/opencrypto/crypto.c == --- head/sys/opencrypto/crypto.cMon Oct 19 17:35:45 2020 (r366843) +++ head/sys/opencrypto/crypto.cMon Oct 19 18:21:41 2020 (r366844) @@ -1142,6 +1142,7 @@ crypto_kregister(u_int32_t driverid, int kalg, u_int32 , kalg , flags ); + gone_in_dev(cap->cc_dev, 14, "asymmetric crypto"); err = 0; } else err = EINVAL; Modified: head/sys/opencrypto/cryptodev.c == --- head/sys/opencrypto/cryptodev.c Mon Oct 19 17:35:45 2020 (r366843) +++ head/sys/opencrypto/cryptodev.c Mon Oct 19 18:21:41 2020 (r366844) @@ -346,6 +346,11 @@ SYSCTL_BOOL(_kern_crypto, OID_AUTO, cryptodev_separate _separate_aad, 0, "Use separate AAD buffer for /dev/crypto requests."); +static struct timeval warninterval = { .tv_sec = 60, .tv_usec = 0 }; +SYSCTL_TIMEVAL_SEC(_kern, OID_AUTO, cryptodev_warn_interval, CTLFLAG_RW, +, +"Delay in seconds between warnings of deprecated /dev/crypto algorithms"); + static int cryptof_ioctl(struct file *, u_long, void *, struct ucred *, struct thread *); static int cryptof_stat(struct file *, struct stat *, @@ -419,6 +424,7 @@ cryptof_ioctl( struct ucred *active_cred, struct thread *td) { + static struct timeval keywarn, featwarn; struct crypto_session_params csp; struct fcrypt *fcr = fp->f_data; struct csession *cse; @@ -818,6 +824,10 @@ bail: break; case CIOCKEY: case CIOCKEY2: + if (ratecheck(, )) + gone_in(14, + "Asymmetric crypto operations via /dev/crypto"); + if (!crypto_userasymcrypto) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); return (EPERM); /* XXX compat? */ @@ -833,6 +843,10 @@ bail: mtx_unlock(); break; case CIOCASYMFEAT: + if (ratecheck(, )) + gone_in(14, + "Asymmetric crypto features via /dev/crypto"); + if (!crypto_userasymcrypto) { /* * NB: if user asym crypto operations are ___ 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: r366843 - head/sys/i386/i386
On Mon, Oct 19, 2020 at 05:35:46PM +, John Baldwin wrote: > Author: jhb > Date: Mon Oct 19 17:35:45 2020 > New Revision: 366843 > URL: https://svnweb.freebsd.org/changeset/base/366843 > > Log: > Properly clear PCB_KERNNPX in fpu_kern_leave(). > > PR: 250423 > Reported by:CI > Tested by: lwhsu > > Modified: > head/sys/i386/i386/npx.c > > Modified: head/sys/i386/i386/npx.c > == > --- head/sys/i386/i386/npx.c Mon Oct 19 17:07:19 2020(r366842) > +++ head/sys/i386/i386/npx.c Mon Oct 19 17:35:45 2020(r366843) > @@ -1475,7 +1475,7 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx > if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0) { > pcb->pcb_flags |= PCB_NPXINITDONE; > if ((pcb->pcb_flags & PCB_KERNNPX_THR) == 0) > - pcb->pcb_flags |= ~PCB_KERNNPX; > + pcb->pcb_flags &= ~PCB_KERNNPX; > } else if ((pcb->pcb_flags & PCB_KERNNPX_THR) == 0) > pcb->pcb_flags &= ~(PCB_NPXINITDONE | PCB_KERNNPX); > } else { My bad, thank you for fixing this. ___ 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: r366843 - head/sys/i386/i386
Author: jhb Date: Mon Oct 19 17:35:45 2020 New Revision: 366843 URL: https://svnweb.freebsd.org/changeset/base/366843 Log: Properly clear PCB_KERNNPX in fpu_kern_leave(). PR: 250423 Reported by: CI Tested by:lwhsu Modified: head/sys/i386/i386/npx.c Modified: head/sys/i386/i386/npx.c == --- head/sys/i386/i386/npx.cMon Oct 19 17:07:19 2020(r366842) +++ head/sys/i386/i386/npx.cMon Oct 19 17:35:45 2020(r366843) @@ -1475,7 +1475,7 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx if ((pcb->pcb_flags & PCB_NPXUSERINITDONE) != 0) { pcb->pcb_flags |= PCB_NPXINITDONE; if ((pcb->pcb_flags & PCB_KERNNPX_THR) == 0) - pcb->pcb_flags |= ~PCB_KERNNPX; + pcb->pcb_flags &= ~PCB_KERNNPX; } else if ((pcb->pcb_flags & PCB_KERNNPX_THR) == 0) pcb->pcb_flags &= ~(PCB_NPXINITDONE | PCB_KERNNPX); } else { ___ 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: r366842 - in head: sys/netinet sys/netinet6 usr.bin/netstat
Author: markj Date: Mon Oct 19 17:07:19 2020 New Revision: 366842 URL: https://svnweb.freebsd.org/changeset/base/366842 Log: icmp6: Count packets dropped due to an invalid hop limit Pad the icmp6stat structure so that we can add more counters in the future without breaking compatibility again, last done in r358620. Annotate the rarely executed error paths with __predict_false while here. Reviewed by: bz, melifaro Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision:https://reviews.freebsd.org/D26578 Modified: head/sys/netinet/icmp6.h head/sys/netinet6/icmp6.c head/sys/netinet6/nd6_nbr.c head/sys/netinet6/nd6_rtr.c head/usr.bin/netstat/inet6.c Modified: head/sys/netinet/icmp6.h == --- head/sys/netinet/icmp6.hMon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet/icmp6.hMon Oct 19 17:07:19 2020(r366842) @@ -639,6 +639,8 @@ struct icmp6stat { uint64_t icp6s_overflowprfx;/* Too many prefixes. */ uint64_t icp6s_overflownndp;/* Too many neighbour entries. */ uint64_t icp6s_overflowredirect;/* Too many redirects. */ + uint64_t icp6s_invlhlim;/* Invalid hop limit. */ + uint64_t icp6s_spare[32]; }; #ifdef _KERNEL Modified: head/sys/netinet6/icmp6.c == --- head/sys/netinet6/icmp6.c Mon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet6/icmp6.c Mon Oct 19 17:07:19 2020(r366842) @@ -2261,7 +2261,8 @@ icmp6_redirect_input(struct mbuf *m, int off) ip6_sprintf(ip6buf, ))); goto bad; } - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "ICMP6 redirect sent from %s rejected; " "hlim=%d (must be 255)\n", Modified: head/sys/netinet6/nd6_nbr.c == --- head/sys/netinet6/nd6_nbr.c Mon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet6/nd6_nbr.c Mon Oct 19 17:07:19 2020(r366842) @@ -136,7 +136,8 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) ifp = m->m_pkthdr.rcvif; ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "nd6_ns_input: invalid hlim (%d) from %s to %s on %s\n", ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), @@ -641,7 +642,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) ifp = m->m_pkthdr.rcvif; ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "nd6_na_input: invalid hlim (%d) from %s to %s on %s\n", ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), Modified: head/sys/netinet6/nd6_rtr.c == --- head/sys/netinet6/nd6_rtr.c Mon Oct 19 16:57:59 2020(r366841) +++ head/sys/netinet6/nd6_rtr.c Mon Oct 19 17:07:19 2020(r366842) @@ -177,7 +177,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) /* Sanity checks */ ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "%s: invalid hlim (%d) from %s to %s on %s\n", __func__, ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), @@ -376,7 +377,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) goto freeit; ip6 = mtod(m, struct ip6_hdr *); - if (ip6->ip6_hlim != 255) { + if (__predict_false(ip6->ip6_hlim != 255)) { + ICMP6STAT_INC(icp6s_invlhlim); nd6log((LOG_ERR, "%s: invalid hlim (%d) from %s to %s on %s\n", __func__, ip6->ip6_hlim, ip6_sprintf(ip6bufs, >ip6_src), Modified: head/usr.bin/netstat/inet6.c == --- head/usr.bin/netstat/inet6.cMon Oct 19 16:57:59 2020 (r366841) +++ head/usr.bin/netstat/inet6.cMon Oct 19 17:07:19 2020 (r366842) @@ -1063,6 +1063,8 @@ icmp6_stats(u_long off, const char *name, int af1 __un "{N:/neighbour entries overflow%s}\n"); p(icp6s_overflowredirect, "\t{:redirect-overflows/%ju} " "{N:/redirect overflow%s}\n"); + p(icp6s_invlhlim, "\t{:dropped-invalid-hop-limit/%ju} " +
svn commit: r366841 - head/sys/kern
Author: markj Date: Mon Oct 19 16:57:59 2020 New Revision: 366841 URL: https://svnweb.freebsd.org/changeset/base/366841 Log: link_elf_obj: Colour VM objects This will cause the VM to back sufficiently large .text sections, such as those in zfs.ko or amdgpu.ko on amd64, with superpage mappings when possible. Reviewed by: alc, kib MFC after:1 week Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26802 Modified: head/sys/kern/link_elf_obj.c Modified: head/sys/kern/link_elf_obj.c == --- head/sys/kern/link_elf_obj.cMon Oct 19 16:57:40 2020 (r366840) +++ head/sys/kern/link_elf_obj.cMon Oct 19 16:57:59 2020 (r366841) @@ -914,6 +914,9 @@ link_elf_load_file(linker_class_t cls, const char *fil error = ENOMEM; goto out; } +#if VM_NRESERVLEVEL > 0 + vm_object_color(ef->object, 0); +#endif /* * In order to satisfy amd64's architectural requirements on the ___ 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: r366840 - head/sys/vm
Author: markj Date: Mon Oct 19 16:57:40 2020 New Revision: 366840 URL: https://svnweb.freebsd.org/changeset/base/366840 Log: uma: Respect uk_reserve in keg_drain() When a reserve of free items is configured for a zone, the reserve must not be reclaimed under memory pressure. Modify keg_drain() to simply respect the reserved pool. While here remove an always-false uk_freef == NULL check (kegs that shouldn't be drained should set _NOFREE instead), and make sure that the keg_drain() KTR statement does not reference an uninitialized variable. Reviewed by: alc, rlibby Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26772 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Mon Oct 19 16:55:03 2020(r366839) +++ head/sys/vm/uma_core.c Mon Oct 19 16:57:40 2020(r366840) @@ -1415,47 +1415,81 @@ keg_free_slab(uma_keg_t keg, uma_slab_t slab, int star uma_total_dec(PAGE_SIZE * keg->uk_ppera); } -/* - * Frees pages from a keg back to the system. This is done on demand from - * the pageout daemon. - * - * Returns nothing. - */ static void -keg_drain(uma_keg_t keg) +keg_drain_domain(uma_keg_t keg, int domain) { struct slabhead freeslabs; uma_domain_t dom; uma_slab_t slab, tmp; - int i, n; + uint32_t i, stofree, stokeep, partial; - if (keg->uk_flags & UMA_ZONE_NOFREE || keg->uk_freef == NULL) - return; + dom = >uk_domain[domain]; + LIST_INIT(); - for (i = 0; i < vm_ndomains; i++) { - CTR4(KTR_UMA, "keg_drain %s(%p) domain %d free items: %u", - keg->uk_name, keg, i, dom->ud_free_items); - dom = >uk_domain[i]; - LIST_INIT(); + CTR4(KTR_UMA, "keg_drain %s(%p) domain %d free items: %u", + keg->uk_name, keg, i, dom->ud_free_items); - KEG_LOCK(keg, i); - if ((keg->uk_flags & UMA_ZFLAG_HASH) != 0) { - LIST_FOREACH(slab, >ud_free_slab, us_link) - UMA_HASH_REMOVE(>uk_hash, slab); - } - n = dom->ud_free_slabs; + KEG_LOCK(keg, domain); + + /* +* Are the free items in partially allocated slabs sufficient to meet +* the reserve? If not, compute the number of fully free slabs that must +* be kept. +*/ + partial = dom->ud_free_items - dom->ud_free_slabs * keg->uk_ipers; + if (partial < keg->uk_reserve) { + stokeep = min(dom->ud_free_slabs, + howmany(keg->uk_reserve - partial, keg->uk_ipers)); + } else { + stokeep = 0; + } + stofree = dom->ud_free_slabs - stokeep; + + /* +* Partition the free slabs into two sets: those that must be kept in +* order to maintain the reserve, and those that may be released back to +* the system. Since one set may be much larger than the other, +* populate the smaller of the two sets and swap them if necessary. +*/ + for (i = min(stofree, stokeep); i > 0; i--) { + slab = LIST_FIRST(>ud_free_slab); + LIST_REMOVE(slab, us_link); + LIST_INSERT_HEAD(, slab, us_link); + } + if (stofree > stokeep) LIST_SWAP(, >ud_free_slab, uma_slab, us_link); - dom->ud_free_slabs = 0; - dom->ud_free_items -= n * keg->uk_ipers; - dom->ud_pages -= n * keg->uk_ppera; - KEG_UNLOCK(keg, i); - LIST_FOREACH_SAFE(slab, , us_link, tmp) - keg_free_slab(keg, slab, keg->uk_ipers); + if ((keg->uk_flags & UMA_ZFLAG_HASH) != 0) { + LIST_FOREACH(slab, , us_link) + UMA_HASH_REMOVE(>uk_hash, slab); } + dom->ud_free_items -= stofree * keg->uk_ipers; + dom->ud_free_slabs -= stofree; + dom->ud_pages -= stofree * keg->uk_ppera; + KEG_UNLOCK(keg, domain); + + LIST_FOREACH_SAFE(slab, , us_link, tmp) + keg_free_slab(keg, slab, keg->uk_ipers); } +/* + * Frees pages from a keg back to the system. This is done on demand from + * the pageout daemon. + * + * Returns nothing. + */ static void +keg_drain(uma_keg_t keg) +{ + int i; + + if ((keg->uk_flags & UMA_ZONE_NOFREE) != 0) + return; + for (i = 0; i < vm_ndomains; i++) + keg_drain_domain(keg, i); +} + +static void zone_reclaim(uma_zone_t zone, int waitok, bool drain) { @@ -2411,6 +2445,9 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "align", CTLFLAG_RD, >uk_align, 0, "item alignment mask"); +
svn commit: r366839 - head/sys/vm
Author: markj Date: Mon Oct 19 16:55:03 2020 New Revision: 366839 URL: https://svnweb.freebsd.org/changeset/base/366839 Log: uma: Avoid depleting keg reserves when filling a bucket zone_import() fetches a free or partially free slab from the keg and then uses its items to populate an array, typically filling a bucket. If a single allocation causes the keg to drop below its minimum reserve, the inner loop ends. However, if the bucket is still not full and M_USE_RESERVE is specified, the outer loop will continue to fetch items from the keg. If M_USE_RESERVE is specified and the number of free items is below the reserved limit, we should return only a single item. Otherwise, if the bucket size is larger than the reserve, all of the reserved items may end up in a single per-CPU bucket, invisible to other CPUs. Reviewed by: rlibby MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26771 Modified: head/sys/vm/uma_core.c Modified: head/sys/vm/uma_core.c == --- head/sys/vm/uma_core.c Mon Oct 19 16:54:06 2020(r366838) +++ head/sys/vm/uma_core.c Mon Oct 19 16:55:03 2020(r366839) @@ -3734,10 +3734,17 @@ zone_import(void *arg, void **bucket, int max, int dom stripe = howmany(max, vm_ndomains); #endif dom = >uk_domain[slab->us_domain]; - while (slab->us_freecount && i < max) { + do { bucket[i++] = slab_alloc_item(keg, slab); - if (dom->ud_free_items <= keg->uk_reserve) - break; + if (dom->ud_free_items <= keg->uk_reserve) { + /* +* Avoid depleting the reserve after a +* successful item allocation, even if +* M_USE_RESERVE is specified. +*/ + KEG_UNLOCK(keg, slab->us_domain); + goto out; + } #ifdef NUMA /* * If the zone is striped we pick a new slab for every @@ -3751,13 +3758,14 @@ zone_import(void *arg, void **bucket, int max, int dom vm_ndomains > 1 && --stripe == 0) break; #endif - } + } while (slab->us_freecount != 0 && i < max); KEG_UNLOCK(keg, slab->us_domain); + /* Don't block if we allocated any successfully. */ flags &= ~M_WAITOK; flags |= M_NOWAIT; } - +out: return i; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366838 - head/sys/kern
Author: markj Date: Mon Oct 19 16:54:06 2020 New Revision: 366838 URL: https://svnweb.freebsd.org/changeset/base/366838 Log: vmem: Allocate btags before looping in vmem_xalloc() BT_MAXALLOC (4) is the number of boundary tags required to complete an allocation in the worst case: two to clip a free segment, and two to import from a parent arena. vmem_xalloc() preallocates four boundary tags before attempting a search to simplify the segment allocation code. It implements a loop that: 1) ensures that BT_MAXALLOC boundary tags are available, 2) attempts to find and clip a free segment satisfying the allocation constraints, and failing that, 3) attempts to import a segment. On !UMA_MD_SMALL_ALLOC platforms the btag zone has to handle recusion: it needs boundary tags to allocate boundary tags. Thus we reserve 2 * BT_MAXALLOC * mp_ncpus tags for use when recursing: the factor of 2 is because there are two layers of vmem arenas, the per-domain arena and global arena. For a single thread, 2 * BT_MAXALLOC tags should be sufficient. Because of the way the loop is structured, BT_MAXALLOC tags are not sufficient. The first bt_fill() call may allocate BT_MAXALLOC tags, then import a segment (consuming two tags), then attempt to top up the preallocation before carving into the imported free segment, thus requiring up to six tags in the worst case. Because we don't preallocate that many, this bug can cause deadlocks in rare scenarios. Fix the problem by moving the preallocation out the loop. This assumes that only a single import is ever required to satisfy an allocation request. Thanks to manu, emaste and lwhsu for helping test debug patches. Reported by: Jenkins (hardware CI lab) Reviewed by: alc, kib, rlibby MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26770 Modified: head/sys/kern/subr_vmem.c Modified: head/sys/kern/subr_vmem.c == --- head/sys/kern/subr_vmem.c Mon Oct 19 16:52:27 2020(r366837) +++ head/sys/kern/subr_vmem.c Mon Oct 19 16:54:06 2020(r366838) @@ -368,6 +368,24 @@ bt_free(vmem_t *vm, bt_t *bt) } /* + * Hide MAXALLOC tags before dropping the arena lock to ensure that a + * concurrent allocation attempt does not grab them. + */ +static void +bt_save(vmem_t *vm) +{ + KASSERT(vm->vm_nfreetags >= BT_MAXALLOC, + ("%s: insufficient free tags %d", __func__, vm->vm_nfreetags)); + vm->vm_nfreetags -= BT_MAXALLOC; +} + +static void +bt_restore(vmem_t *vm) +{ + vm->vm_nfreetags += BT_MAXALLOC; +} + +/* * freelist[0] ... [1, 1] * freelist[1] ... [2, 2] * : @@ -911,16 +929,11 @@ vmem_import(vmem_t *vm, vmem_size_t size, vmem_size_t if (vm->vm_limit != 0 && vm->vm_limit < vm->vm_size + size) return (ENOMEM); - /* -* Hide MAXALLOC tags so we're guaranteed to be able to add this -* span and the tag we want to allocate from it. -*/ - MPASS(vm->vm_nfreetags >= BT_MAXALLOC); - vm->vm_nfreetags -= BT_MAXALLOC; + bt_save(vm); VMEM_UNLOCK(vm); error = (vm->vm_importfn)(vm->vm_arg, size, flags, ); VMEM_LOCK(vm); - vm->vm_nfreetags += BT_MAXALLOC; + bt_restore(vm); if (error) return (ENOMEM); @@ -1048,19 +1061,23 @@ vmem_try_fetch(vmem_t *vm, const vmem_size_t size, vme */ if (vm->vm_qcache_max != 0 || vm->vm_reclaimfn != NULL) { avail = vm->vm_size - vm->vm_inuse; + bt_save(vm); VMEM_UNLOCK(vm); if (vm->vm_qcache_max != 0) qc_drain(vm); if (vm->vm_reclaimfn != NULL) vm->vm_reclaimfn(vm, flags); VMEM_LOCK(vm); + bt_restore(vm); /* If we were successful retry even NOWAIT. */ if (vm->vm_size - vm->vm_inuse > avail) return (1); } if ((flags & M_NOWAIT) != 0) return (0); + bt_save(vm); VMEM_CONDVAR_WAIT(vm); + bt_restore(vm); return (1); } @@ -1108,13 +1125,14 @@ vmem_xalloc_nextfit(vmem_t *vm, const vmem_size_t size error = ENOMEM; VMEM_LOCK(vm); -retry: + /* * Make sure we have enough tags to complete the operation. */ if (bt_fill(vm, flags) != 0) goto out; +retry: /* * Find the next free tag meeting our constraints. If one is found, * perform the allocation. @@ -1390,15 +1408,14 @@ vmem_xalloc(vmem_t *vm, const vmem_size_t size0, vmem_ */ first = bt_freehead_toalloc(vm, size, strat); VMEM_LOCK(vm); - for (;;) { - /* -* Make sure we have enough tags to
svn commit: r366837 - head/sys/kern
Author: markj Date: Mon Oct 19 16:52:27 2020 New Revision: 366837 URL: https://svnweb.freebsd.org/changeset/base/366837 Log: vmem: Simplify bt_fill() callers a bit No functional change intended. Reviewed by: alc, kib, rlibby MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26769 Modified: head/sys/kern/subr_vmem.c Modified: head/sys/kern/subr_vmem.c == --- head/sys/kern/subr_vmem.c Mon Oct 19 15:52:42 2020(r366836) +++ head/sys/kern/subr_vmem.c Mon Oct 19 16:52:27 2020(r366837) @@ -266,8 +266,8 @@ bt_isfree(bt_t *bt) * allocation will not fail once bt_fill() passes. To do so we cache * at least the maximum possible tag allocations in the arena. */ -static int -bt_fill(vmem_t *vm, int flags) +static __noinline int +_bt_fill(vmem_t *vm, int flags) { bt_t *bt; @@ -307,6 +307,14 @@ bt_fill(vmem_t *vm, int flags) return 0; } +static inline int +bt_fill(vmem_t *vm, int flags) +{ + if (vm->vm_nfreetags >= BT_MAXALLOC) + return (0); + return (_bt_fill(vm, flags)); +} + /* * Pop a tag off of the freetag stack. */ @@ -1104,7 +1112,7 @@ retry: /* * Make sure we have enough tags to complete the operation. */ - if (vm->vm_nfreetags < BT_MAXALLOC && bt_fill(vm, flags) != 0) + if (bt_fill(vm, flags) != 0) goto out; /* @@ -1387,11 +1395,9 @@ vmem_xalloc(vmem_t *vm, const vmem_size_t size0, vmem_ * Make sure we have enough tags to complete the * operation. */ - if (vm->vm_nfreetags < BT_MAXALLOC && - bt_fill(vm, flags) != 0) { - error = ENOMEM; + error = bt_fill(vm, flags); + if (error != 0) break; - } /* * Scan freelists looking for a tag that satisfies the @@ -1510,13 +1516,12 @@ vmem_add(vmem_t *vm, vmem_addr_t addr, vmem_size_t siz { int error; - error = 0; flags &= VMEM_FLAGS; + VMEM_LOCK(vm); - if (vm->vm_nfreetags >= BT_MAXALLOC || bt_fill(vm, flags) == 0) + error = bt_fill(vm, flags); + if (error == 0) vmem_add1(vm, addr, size, BT_TYPE_SPAN_STATIC); - else - error = ENOMEM; VMEM_UNLOCK(vm); return (error); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366836 - head/sys/arm64/arm64
Author: andrew Date: Mon Oct 19 15:52:42 2020 New Revision: 366836 URL: https://svnweb.freebsd.org/changeset/base/366836 Log: Remove unused labels from the arm64 casueword* These are unused so can be removed. While here renumber the remaining label to be 1. Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/support.S Modified: head/sys/arm64/arm64/support.S == --- head/sys/arm64/arm64/support.S Mon Oct 19 15:50:58 2020 (r366835) +++ head/sys/arm64/arm64/support.S Mon Oct 19 15:52:42 2020 (r366836) @@ -64,11 +64,11 @@ ENTRY(casueword32) mov w5, #1 SET_FAULT_HANDLER(x6, x4) /* And set it */ ENTER_USER_ACCESS(w6, x4) -1: ldxrw4, [x0]/* Load-exclusive the data */ + ldxrw4, [x0]/* Load-exclusive the data */ cmp w4, w1 /* Compare */ - b.ne2f /* Not equal, exit */ + b.ne1f /* Not equal, exit */ stxrw5, w3, [x0]/* Store the new data */ -2: EXIT_USER_ACCESS(w6) +1: EXIT_USER_ACCESS(w6) SET_FAULT_HANDLER(xzr, x6) /* Reset the fault handler */ str w4, [x2]/* Store the read data */ mov w0, w5 /* Result same as store status */ @@ -84,11 +84,11 @@ ENTRY(casueword) mov w5, #1 SET_FAULT_HANDLER(x6, x4) /* And set it */ ENTER_USER_ACCESS(w6, x4) -1: ldxrx4, [x0]/* Load-exclusive the data */ + ldxrx4, [x0]/* Load-exclusive the data */ cmp x4, x1 /* Compare */ - b.ne2f /* Not equal, exit */ + b.ne1f /* Not equal, exit */ stxrw5, x3, [x0]/* Store the new data */ -2: EXIT_USER_ACCESS(w6) +1: EXIT_USER_ACCESS(w6) SET_FAULT_HANDLER(xzr, x6) /* Reset the fault handler */ str x4, [x2]/* Store the read data */ mov w0, w5 /* Result same as store 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: r366835 - in head/sys: dev/iommu x86/iommu
Author: br Date: Mon Oct 19 15:50:58 2020 New Revision: 366835 URL: https://svnweb.freebsd.org/changeset/base/366835 Log: Assign the reserved apic region (GAS entry) to the iommu domain msi_entry. Requested by: kib Reviewed by: kib Sponsored by: Innovate DSbD Differential Revision:https://reviews.freebsd.org/D26859 Modified: head/sys/dev/iommu/iommu.h head/sys/dev/iommu/iommu_gas.c head/sys/x86/iommu/intel_ctx.c Modified: head/sys/dev/iommu/iommu.h == --- head/sys/dev/iommu/iommu.h Mon Oct 19 15:24:35 2020(r366834) +++ head/sys/dev/iommu/iommu.h Mon Oct 19 15:50:58 2020(r366835) @@ -197,7 +197,7 @@ void iommu_gas_free_region(struct iommu_domain *domain int iommu_gas_map_region(struct iommu_domain *domain, struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma); int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start, -iommu_gaddr_t end); +iommu_gaddr_t end, struct iommu_map_entry **entry0); void iommu_set_buswide_ctx(struct iommu_unit *unit, u_int busno); bool iommu_is_buswide_ctx(struct iommu_unit *unit, u_int busno); Modified: head/sys/dev/iommu/iommu_gas.c == --- head/sys/dev/iommu/iommu_gas.c Mon Oct 19 15:24:35 2020 (r366834) +++ head/sys/dev/iommu/iommu_gas.c Mon Oct 19 15:50:58 2020 (r366835) @@ -677,7 +677,7 @@ iommu_gas_map_region(struct iommu_domain *domain, stru int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start, -iommu_gaddr_t end) +iommu_gaddr_t end, struct iommu_map_entry **entry0) { struct iommu_map_entry *entry; int error; @@ -692,6 +692,8 @@ iommu_gas_reserve_region(struct iommu_domain *domain, IOMMU_DOMAIN_UNLOCK(domain); if (error != 0) iommu_gas_free_entry(domain, entry); + else if (entry0 != NULL) + *entry0 = entry; return (error); } Modified: head/sys/x86/iommu/intel_ctx.c == --- head/sys/x86/iommu/intel_ctx.c Mon Oct 19 15:24:35 2020 (r366834) +++ head/sys/x86/iommu/intel_ctx.c Mon Oct 19 15:50:58 2020 (r366835) @@ -366,7 +366,7 @@ dmar_domain_alloc(struct dmar_unit *dmar, bool id_mapp goto fail; /* Disable local apic region access */ error = iommu_gas_reserve_region(iodom, 0xfee0, - 0xfeef + 1); + 0xfeef + 1, >msi_entry); if (error != 0) goto fail; } ___ 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: r366834 - head/sys/amd64/vmm/intel
Author: markj Date: Mon Oct 19 15:24:35 2020 New Revision: 366834 URL: https://svnweb.freebsd.org/changeset/base/366834 Log: vmx: Implement pmap (de)activation in C Rewrite the code that maintains pm_active and invalidates EPTP-tagged TLB entries in C. Previously this work was done in vmx_enter_guest(), in assembly, but there is no good reason for that and it makes the TLB invalidation algorithm for nested page tables harder to review. No functional change intended. Now, an error from the invept instruction results in a kernel panic rather than a vmexit. Such errors should occur only as a result of VMM bugs. Reviewed by: grehan, kib MFC after:2 weeks Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D26830 Modified: head/sys/amd64/vmm/intel/vmx.c head/sys/amd64/vmm/intel/vmx.h head/sys/amd64/vmm/intel/vmx_genassym.c head/sys/amd64/vmm/intel/vmx_support.S Modified: head/sys/amd64/vmm/intel/vmx.c == --- head/sys/amd64/vmm/intel/vmx.c Mon Oct 19 13:10:21 2020 (r366833) +++ head/sys/amd64/vmm/intel/vmx.c Mon Oct 19 15:24:35 2020 (r366834) @@ -2835,7 +2835,6 @@ vmx_exit_inst_error(struct vmxctx *vmxctx, int rc, str switch (rc) { case VMX_VMRESUME_ERROR: case VMX_VMLAUNCH_ERROR: - case VMX_INVEPT_ERROR: vmexit->u.vmx.inst_type = rc; break; default: @@ -2940,6 +2939,29 @@ vmx_dr_leave_guest(struct vmxctx *vmxctx) write_rflags(read_rflags() | vmxctx->host_tf); } +static __inline void +vmx_pmap_activate(struct vmx *vmx, pmap_t pmap) +{ + long eptgen; + int cpu; + + cpu = curcpu; + + CPU_SET_ATOMIC(cpu, >pm_active); + eptgen = atomic_load_long(>pm_eptgen); + if (eptgen != vmx->eptgen[cpu]) { + vmx->eptgen[cpu] = eptgen; + invept(INVEPT_TYPE_SINGLE_CONTEXT, + (struct invept_desc){ .eptp = vmx->eptp, ._res = 0 }); + } +} + +static __inline void +vmx_pmap_deactivate(struct vmx *vmx, pmap_t pmap) +{ + CPU_CLR_ATOMIC(curcpu, >pm_active); +} + static int vmx_run(void *arg, int vcpu, register_t rip, pmap_t pmap, struct vm_eventinfo *evinfo) @@ -3088,11 +3110,19 @@ vmx_run(void *arg, int vcpu, register_t rip, pmap_t pm */ vmx_msr_guest_enter_tsc_aux(vmx, vcpu); - vmx_run_trace(vmx, vcpu); vmx_dr_enter_guest(vmxctx); + + /* +* Mark the EPT as active on this host CPU and invalidate +* EPTP-tagged TLB entries if required. +*/ + vmx_pmap_activate(vmx, pmap); + + vmx_run_trace(vmx, vcpu); rc = vmx_enter_guest(vmxctx, vmx, launched); - vmx_dr_leave_guest(vmxctx); + vmx_pmap_deactivate(vmx, pmap); + vmx_dr_leave_guest(vmxctx); vmx_msr_guest_exit_tsc_aux(vmx, vcpu); bare_lgdt(); Modified: head/sys/amd64/vmm/intel/vmx.h == --- head/sys/amd64/vmm/intel/vmx.h Mon Oct 19 13:10:21 2020 (r366833) +++ head/sys/amd64/vmm/intel/vmx.h Mon Oct 19 15:24:35 2020 (r366834) @@ -142,7 +142,6 @@ CTASSERT((offsetof(struct vmx, pir_desc[0]) & 63) == 0 #defineVMX_GUEST_VMEXIT0 #defineVMX_VMRESUME_ERROR 1 #defineVMX_VMLAUNCH_ERROR 2 -#defineVMX_INVEPT_ERROR3 intvmx_enter_guest(struct vmxctx *ctx, struct vmx *vmx, int launched); void vmx_call_isr(uintptr_t entry); Modified: head/sys/amd64/vmm/intel/vmx_genassym.c == --- head/sys/amd64/vmm/intel/vmx_genassym.c Mon Oct 19 13:10:21 2020 (r366833) +++ head/sys/amd64/vmm/intel/vmx_genassym.c Mon Oct 19 15:24:35 2020 (r366834) @@ -70,17 +70,12 @@ ASSYM(VMXCTX_HOST_RSP, offsetof(struct vmxctx, host_rs ASSYM(VMXCTX_HOST_RBX, offsetof(struct vmxctx, host_rbx)); ASSYM(VMXCTX_INST_FAIL_STATUS, offsetof(struct vmxctx, inst_fail_status)); -ASSYM(VMXCTX_PMAP, offsetof(struct vmxctx, pmap)); -ASSYM(VMX_EPTGEN, offsetof(struct vmx, eptgen)); -ASSYM(VMX_EPTP, offsetof(struct vmx, eptp)); - ASSYM(VM_FAIL_INVALID, VM_FAIL_INVALID); ASSYM(VM_FAIL_VALID, VM_FAIL_VALID); ASSYM(VMX_GUEST_VMEXIT, VMX_GUEST_VMEXIT); ASSYM(VMX_VMRESUME_ERROR, VMX_VMRESUME_ERROR); ASSYM(VMX_VMLAUNCH_ERROR, VMX_VMLAUNCH_ERROR); -ASSYM(VMX_INVEPT_ERROR, VMX_INVEPT_ERROR); ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); Modified: head/sys/amd64/vmm/intel/vmx_support.S == --- head/sys/amd64/vmm/intel/vmx_support.S Mon Oct 19 13:10:21 2020 (r366833) +++
Re: svn commit: r366833 - in head/sys: dev/iommu kern sys
On 19 Oct 2020, at 14:10, Ruslan Bukin wrote: > > +#ifndef _DEV_IOMMU_IOMMU_MSI_H_ > +#define _DEV_IOMMU_IOMMU_MSI_H_ > + > +#include > + > +struct iommu_unit; This seems unused, perhaps left from a previous patch version? Jess ___ 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: r366833 - in head/sys: dev/iommu kern sys
Author: br Date: Mon Oct 19 13:10:21 2020 New Revision: 366833 URL: https://svnweb.freebsd.org/changeset/base/366833 Log: Manage MSI iommu pages. This allows the interrupt controller driver only need a small change to create a map for the page the device will write to raise an interrupt. Submitted by: andrew Reviewed by: kib Sponsored by: Innovate DSbD Differential Revision:https://reviews.freebsd.org/D26705 Added: head/sys/dev/iommu/iommu_msi.h (contents, props changed) Modified: head/sys/dev/iommu/iommu.h head/sys/dev/iommu/iommu_gas.c head/sys/kern/msi_if.m head/sys/kern/subr_intr.c head/sys/sys/intr.h Modified: head/sys/dev/iommu/iommu.h == --- head/sys/dev/iommu/iommu.h Mon Oct 19 12:46:03 2020(r366832) +++ head/sys/dev/iommu/iommu.h Mon Oct 19 13:10:21 2020(r366833) @@ -111,6 +111,9 @@ struct iommu_domain { iommu_gaddr_t end; /* (c) Highest address + 1 in the guest AS */ struct iommu_map_entry *first_place, *last_place; /* (d) */ + struct iommu_map_entry *msi_entry; /* (d) Arch-specific */ + iommu_gaddr_t msi_base; /* (d) Arch-specific */ + vm_paddr_t msi_phys;/* (d) Arch-specific */ u_int flags;/* (u) */ }; Modified: head/sys/dev/iommu/iommu_gas.c == --- head/sys/dev/iommu/iommu_gas.c Mon Oct 19 12:46:03 2020 (r366832) +++ head/sys/dev/iommu/iommu_gas.c Mon Oct 19 13:10:21 2020 (r366833) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -722,6 +723,69 @@ iommu_map(struct iommu_domain *domain, ma, res); return (error); +} + +int +iommu_map_msi(struct iommu_ctx *ctx, iommu_gaddr_t size, int offset, +u_int eflags, u_int flags, vm_page_t *ma) +{ + struct iommu_domain *domain; + struct iommu_map_entry *entry; + int error; + + error = 0; + domain = ctx->domain; + + /* Check if there is already an MSI page allocated */ + IOMMU_DOMAIN_LOCK(domain); + entry = domain->msi_entry; + IOMMU_DOMAIN_UNLOCK(domain); + + if (entry == NULL) { + error = iommu_gas_map(domain, >tag->common, size, offset, + eflags, flags, ma, ); + IOMMU_DOMAIN_LOCK(domain); + if (error == 0) { + if (domain->msi_entry == NULL) { + MPASS(domain->msi_base == 0); + MPASS(domain->msi_phys == 0); + + domain->msi_entry = entry; + domain->msi_base = entry->start; + domain->msi_phys = VM_PAGE_TO_PHYS(ma[0]); + } else { + /* +* We lost the race and already have an +* MSI page allocated. Free the unneeded entry. +*/ + iommu_gas_free_entry(domain, entry); + } + } else if (domain->msi_entry != NULL) { + /* +* The allocation failed, but another succeeded. +* Return success as there is a valid MSI page. +*/ + error = 0; + } + IOMMU_DOMAIN_UNLOCK(domain); + } + + return (error); +} + +void +iommu_translate_msi(struct iommu_domain *domain, uint64_t *addr) +{ + + *addr = (*addr - domain->msi_phys) + domain->msi_base; + + KASSERT(*addr >= domain->msi_entry->start, + ("%s: Address is below the MSI entry start address (%jx < %jx)", + __func__, (uintmax_t)*addr, (uintmax_t)domain->msi_entry->start)); + + KASSERT(*addr + sizeof(*addr) <= domain->msi_entry->end, + ("%s: Address is above the MSI entry end address (%jx < %jx)", + __func__, (uintmax_t)*addr, (uintmax_t)domain->msi_entry->end)); } int Added: head/sys/dev/iommu/iommu_msi.h == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/iommu/iommu_msi.h Mon Oct 19 13:10:21 2020 (r366833) @@ -0,0 +1,46 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Andrew Turner + * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of
svn commit: r366832 - head/sys/arm64/arm64
Author: andrew Date: Mon Oct 19 12:46:03 2020 New Revision: 366832 URL: https://svnweb.freebsd.org/changeset/base/366832 Log: Split the common arm64 fu* and su* asm to a macro As these are mostly identical split out the common code to a macro. Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/support.S Modified: head/sys/arm64/arm64/support.S == --- head/sys/arm64/arm64/support.S Mon Oct 19 12:06:16 2020 (r366831) +++ head/sys/arm64/arm64/support.S Mon Oct 19 12:46:03 2020 (r366832) @@ -95,15 +95,19 @@ ENTRY(casueword) ret /* Return */ END(casueword) +.macro fsudata insn, ret_reg, user_arg + adr x7, fsu_fault /* Load the fault handler */ + SET_FAULT_HANDLER(x7, x6) /* And set it */ + \insn \ret_reg, [x\user_arg] /* Try accessing the data */ + SET_FAULT_HANDLER(xzr, x6) /* Reset the fault handler */ +.endm + /* * int fubyte(volatile const void *) */ ENTRY(fubyte) check_user_access 0, (VM_MAXUSER_ADDRESS), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x1) /* And set it */ - ldtrb w0, [x0]/* Try loading the data */ - SET_FAULT_HANDLER(xzr, x1) /* Reset the fault handler */ + fsudata ldtrb, w0, 0 ret /* Return */ END(fubyte) @@ -112,10 +116,7 @@ END(fubyte) */ ENTRY(fuword16) check_user_access 0, (VM_MAXUSER_ADDRESS-1), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x1) /* And set it */ - ldtrh w0, [x0]/* Try loading the data */ - SET_FAULT_HANDLER(xzr, x1) /* Reset the fault handler */ + fsudata ldtrh, w0, 0 ret /* Return */ END(fuword16) @@ -124,10 +125,7 @@ END(fuword16) */ ENTRY(fueword32) check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - ldtrw0, [x0]/* Try loading the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata ldtr, w0, 0 str w0, [x1]/* Save the data in kernel space */ mov w0, #0 /* Success */ ret /* Return */ @@ -140,10 +138,7 @@ END(fueword32) ENTRY(fueword) EENTRY(fueword64) check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - ldtrx0, [x0]/* Try loading the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata ldtr, x0, 0 str x0, [x1]/* Save the data in kernel space */ mov x0, #0 /* Success */ ret /* Return */ @@ -155,10 +150,7 @@ END(fueword) */ ENTRY(subyte) check_user_access 0, (VM_MAXUSER_ADDRESS), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttrb w1, [x0]/* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttrb, w1, 0 mov x0, #0 /* Success */ ret /* Return */ END(subyte) @@ -168,10 +160,7 @@ END(subyte) */ ENTRY(suword16) check_user_access 0, (VM_MAXUSER_ADDRESS-1), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttrh w1, [x0]/* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttrh, w1, 0 mov x0, #0 /* Success */ ret /* Return */ END(suword16) @@ -181,10 +170,7 @@ END(suword16) */ ENTRY(suword32) check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb - adr x6, fsu_fault /* Load the fault handler */ - SET_FAULT_HANDLER(x6, x2) /* And set it */ - sttrw1, [x0]/* Try storing the data */ - SET_FAULT_HANDLER(xzr, x2) /* Reset the fault handler */ + fsudata sttr, w1, 0 mov x0, #0 /* Success */ ret /* Return */ END(suword32) @@ -195,10 +181,7 @@ END(suword32) ENTRY(suword) EENTRY(suword64) check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb - adr x6,
svn commit: r366831 - head/sys/arm64/arm64
Author: andrew Date: Mon Oct 19 12:06:16 2020 New Revision: 366831 URL: https://svnweb.freebsd.org/changeset/base/366831 Log: Move the arm64 userspace access checks to macros In the functions that copy between userspace and kernel space we check the user space address is valid before performing the copy. These are mostly identical within each type of function so create two macros to perform the check. Obtained from:CheriBSD Sponsored by: Innovate UK Modified: head/sys/arm64/arm64/copyinout.S head/sys/arm64/arm64/support.S Modified: head/sys/arm64/arm64/copyinout.S == --- head/sys/arm64/arm64/copyinout.SMon Oct 19 10:38:40 2020 (r366830) +++ head/sys/arm64/arm64/copyinout.SMon Oct 19 12:06:16 2020 (r366831) @@ -37,6 +37,14 @@ __FBSDID("$FreeBSD$"); #include "assym.inc" +.macro check_user_access user_arg, size_arg, bad_access_func + addsx6, x\user_arg, x\size_arg + b.cs\bad_access_func + ldr x7, =VM_MAXUSER_ADDRESS + cmp x6, x7 + b.hi\bad_access_func +.endm + /* * Fault handler for the copy{in,out} functions below. */ @@ -55,11 +63,7 @@ END(copyio_fault) */ ENTRY(copyout) cbz x2, 1f - addsx3, x1, x2 - b.cscopyio_fault_nopcb - ldr x4, =VM_MAXUSER_ADDRESS - cmp x3, x4 - b.hicopyio_fault_nopcb + check_user_access 1, 2, copyio_fault_nopcb b copycommon @@ -75,11 +79,7 @@ END(copyout) */ ENTRY(copyin) cbz x2, 1f - addsx3, x0, x2 - b.cscopyio_fault_nopcb - ldr x4, =VM_MAXUSER_ADDRESS - cmp x3, x4 - b.hicopyio_fault_nopcb + check_user_access 0, 2, copyio_fault_nopcb b copycommon Modified: head/sys/arm64/arm64/support.S == --- head/sys/arm64/arm64/support.S Mon Oct 19 10:38:40 2020 (r366830) +++ head/sys/arm64/arm64/support.S Mon Oct 19 12:06:16 2020 (r366831) @@ -38,6 +38,12 @@ __FBSDID("$FreeBSD$"); #include "assym.inc" +.macro check_user_access user_arg, limit, bad_addr_func + ldr x7, =(\limit) + cmp x\user_arg, x7 + b.cs\bad_addr_func +.endm + /* * One of the fu* or su* functions failed, return -1. */ @@ -53,9 +59,7 @@ END(fsu_fault) * int casueword32(volatile uint32_t *, uint32_t, uint32_t *, uint32_t) */ ENTRY(casueword32) - ldr x4, =(VM_MAXUSER_ADDRESS-3) - cmp x0, x4 - b.csfsu_fault_nopcb + check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb adr x6, fsu_fault /* Load the fault handler */ mov w5, #1 SET_FAULT_HANDLER(x6, x4) /* And set it */ @@ -75,9 +79,7 @@ END(casueword32) * int casueword(volatile u_long *, u_long, u_long *, u_long) */ ENTRY(casueword) - ldr x4, =(VM_MAXUSER_ADDRESS-7) - cmp x0, x4 - b.csfsu_fault_nopcb + check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb adr x6, fsu_fault /* Load the fault handler */ mov w5, #1 SET_FAULT_HANDLER(x6, x4) /* And set it */ @@ -97,9 +99,7 @@ END(casueword) * int fubyte(volatile const void *) */ ENTRY(fubyte) - ldr x1, =VM_MAXUSER_ADDRESS - cmp x0, x1 - b.csfsu_fault_nopcb + check_user_access 0, (VM_MAXUSER_ADDRESS), fsu_fault_nopcb adr x6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(x6, x1) /* And set it */ ldtrb w0, [x0]/* Try loading the data */ @@ -111,9 +111,7 @@ END(fubyte) * int fuword(volatile const void *) */ ENTRY(fuword16) - ldr x1, =(VM_MAXUSER_ADDRESS-1) - cmp x0, x1 - b.csfsu_fault_nopcb + check_user_access 0, (VM_MAXUSER_ADDRESS-1), fsu_fault_nopcb adr x6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(x6, x1) /* And set it */ ldtrh w0, [x0]/* Try loading the data */ @@ -125,9 +123,7 @@ END(fuword16) * int32_t fueword32(volatile const void *, int32_t *) */ ENTRY(fueword32) - ldr x2, =(VM_MAXUSER_ADDRESS-3) - cmp x0, x2 - b.csfsu_fault_nopcb + check_user_access 0, (VM_MAXUSER_ADDRESS-3), fsu_fault_nopcb adr x6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(x6, x2) /* And set it */ ldtrw0, [x0]/* Try loading the data */ @@ -143,9 +139,7 @@ END(fueword32) */ ENTRY(fueword) EENTRY(fueword64) - ldr x2, =(VM_MAXUSER_ADDRESS-7) - cmp x0, x2 - b.csfsu_fault_nopcb + check_user_access 0, (VM_MAXUSER_ADDRESS-7), fsu_fault_nopcb adr x6, fsu_fault /* Load the
svn commit: r366830 - head/usr.sbin/efibootmgr
Author: freqlabs Date: Mon Oct 19 10:38:40 2020 New Revision: 366830 URL: https://svnweb.freebsd.org/changeset/base/366830 Log: efibootmgr: Use returned error code for error message, not errno efivar_unix_path_to_device_path returns the error code, it does not set errno. Reviewed by: imp MFC after:1 week Differential Revision:https://reviews.freebsd.org/D26852 Modified: head/usr.sbin/efibootmgr/efibootmgr.c Modified: head/usr.sbin/efibootmgr/efibootmgr.c == --- head/usr.sbin/efibootmgr/efibootmgr.c Mon Oct 19 09:52:52 2020 (r366829) +++ head/usr.sbin/efibootmgr/efibootmgr.c Mon Oct 19 10:38:40 2020 (r366830) @@ -674,11 +674,16 @@ make_boot_var(const char *label, const char *loader, c err(1, "bootvar creation"); if (loader == NULL) errx(1, "Must specify boot loader"); - if (efivar_unix_path_to_device_path(loader, ) != 0) - err(1, "Cannot translate unix loader path '%s' to UEFI", loader); + ret = efivar_unix_path_to_device_path(loader, ); + if (ret != 0) + errc(1, ret, "Cannot translate unix loader path '%s' to UEFI", + loader); if (kernel != NULL) { - if (efivar_unix_path_to_device_path(kernel, ) != 0) - err(1, "Cannot translate unix kernel path '%s' to UEFI", kernel); + ret = efivar_unix_path_to_device_path(kernel, ); + if (ret != 0) + errc(1, ret, + "Cannot translate unix kernel path '%s' to UEFI", + kernel); } else { kerneldp = NULL; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366829 - head/sys/kern
Author: mjg Date: Mon Oct 19 09:52:52 2020 New Revision: 366829 URL: https://svnweb.freebsd.org/changeset/base/366829 Log: cache: refactor negative promotion/demotion handling This will simplify policy changes. Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c == --- head/sys/kern/vfs_cache.c Mon Oct 19 07:26:42 2020(r366828) +++ head/sys/kern/vfs_cache.c Mon Oct 19 09:52:52 2020(r366829) @@ -908,11 +908,37 @@ cache_neg_init(struct namecache *ncp) counter_u64_add(neg_created, 1); } +static bool +cache_neg_hit_prep(struct namecache *ncp) +{ + struct negstate *ns; + + ns = NCP2NEGSTATE(ncp); + if ((ns->neg_flag & NEG_HOT) != 0) + return (true); + return (false); +} + /* + * Nothing to do here but it is provided for completeness as some + * cache_neg_hit_prep callers may end up returning without even + * trying to promote. + */ +#define cache_neg_hit_abort(ncp) do { } while (0) + +static void +cache_neg_hit_finish(struct namecache *ncp) +{ + + SDT_PROBE2(vfs, namecache, lookup, hit__negative, ncp->nc_dvp, ncp->nc_name); + counter_u64_add(numneghits, 1); +} + +/* * Move a negative entry to the hot list. */ static void -cache_neg_promote(struct namecache *ncp) +cache_neg_promote_locked(struct namecache *ncp) { struct neglist *nl; struct negstate *ns; @@ -929,6 +955,25 @@ cache_neg_promote(struct namecache *ncp) } /* + * Move a hot negative entry to the cold list. + */ +static void +cache_neg_demote_locked(struct namecache *ncp) +{ + struct neglist *nl; + struct negstate *ns; + + ns = NCP2NEGSTATE(ncp); + nl = NCP2NEGLIST(ncp); + mtx_assert(>nl_lock, MA_OWNED); + MPASS(ns->neg_flag & NEG_HOT); + TAILQ_REMOVE(>nl_hotlist, ncp, nc_dst); + TAILQ_INSERT_TAIL(>nl_list, ncp, nc_dst); + nl->nl_hotnum--; + ns->neg_flag &= ~NEG_HOT; +} + +/* * Move a negative entry to the hot list if it matches the lookup. * * We have to take locks, but they may be contended and in the worst @@ -996,10 +1041,8 @@ cache_neg_promote_cond(struct vnode *dvp, struct compo goto out_abort; } - cache_neg_promote(ncp); - - SDT_PROBE2(vfs, namecache, lookup, hit__negative, dvp, ncp->nc_name); - counter_u64_add(numneghits, 1); + cache_neg_promote_locked(ncp); + cache_neg_hit_finish(ncp); vfs_smr_exit(); mtx_unlock(>nl_lock); return (true); @@ -1010,17 +1053,13 @@ out_abort: } static void -cache_neg_hit(struct namecache *ncp) +cache_neg_promote(struct namecache *ncp) { struct neglist *nl; - struct negstate *ns; - ns = NCP2NEGSTATE(ncp); - if ((ns->neg_flag & NEG_HOT) != 0) - return; nl = NCP2NEGLIST(ncp); mtx_lock(>nl_lock); - cache_neg_promote(ncp); + cache_neg_promote_locked(ncp); mtx_unlock(>nl_lock); } @@ -1094,11 +1133,7 @@ cache_neg_evict(void) mtx_lock(>nl_lock); ncp = TAILQ_FIRST(>nl_hotlist); if (ncp != NULL) { - ns = NCP2NEGSTATE(ncp); - TAILQ_REMOVE(>nl_hotlist, ncp, nc_dst); - TAILQ_INSERT_TAIL(>nl_list, ncp, nc_dst); - nl->nl_hotnum--; - ns->neg_flag &= ~NEG_HOT; + cache_neg_demote_locked(ncp); } ncp = TAILQ_FIRST(>nl_list); if (ncp == NULL) { @@ -1542,11 +1577,12 @@ negative_success: } } - SDT_PROBE2(vfs, namecache, lookup, hit__negative, dvp, ncp->nc_name); - cache_out_ts(ncp, tsp, ticksp); - counter_u64_add(numneghits, 1); whiteout = (ncp->nc_flag & NCF_WHITE); - cache_neg_hit(ncp); + cache_out_ts(ncp, tsp, ticksp); + if (cache_neg_hit_prep(ncp)) + cache_neg_promote(ncp); + else + cache_neg_hit_finish(ncp); mtx_unlock(dvlp); if (whiteout) cnp->cn_flags |= ISWHITEOUT; @@ -1653,11 +1689,12 @@ negative_success: } } - SDT_PROBE2(vfs, namecache, lookup, hit__negative, dvp, ncp->nc_name); - cache_out_ts(ncp, tsp, ticksp); - counter_u64_add(numneghits, 1); whiteout = (ncp->nc_flag & NCF_WHITE); - cache_neg_hit(ncp); + cache_out_ts(ncp, tsp, ticksp); + if (cache_neg_hit_prep(ncp)) + cache_neg_promote(ncp); + else + cache_neg_hit_finish(ncp); mtx_unlock(blp); if (whiteout) cnp->cn_flags |= ISWHITEOUT; @@ -1669,11 +1706,10 @@ cache_lookup(struct vnode *dvp, struct vnode **vpp, st struct timespec *tsp, int *ticksp) { struct namecache *ncp; - struct negstate *ns; uint32_t hash; enum vgetstate vs; int error; - bool whiteout, neg_hot; + bool
svn commit: r366828 - head/usr.sbin/pkg
Author: bapt Date: Mon Oct 19 07:26:42 2020 New Revision: 366828 URL: https://svnweb.freebsd.org/changeset/base/366828 Log: Use asprintf instead of sbuf Modified: head/usr.sbin/pkg/config.c Modified: head/usr.sbin/pkg/config.c == --- head/usr.sbin/pkg/config.c Mon Oct 19 07:03:04 2020(r366827) +++ head/usr.sbin/pkg/config.c Mon Oct 19 07:26:42 2020(r366828) @@ -32,8 +32,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include +#include #include #include @@ -168,7 +168,7 @@ pkg_get_myabi(char *dest, size_t sz) static void subst_packagesite(const char *abi) { - struct sbuf *newval; + char *newval; const char *variable_string; const char *oldval; @@ -180,14 +180,14 @@ subst_packagesite(const char *abi) if ((variable_string = strstr(oldval, "${ABI}")) == NULL) return; - newval = sbuf_new_auto(); - sbuf_bcat(newval, oldval, variable_string - oldval); - sbuf_cat(newval, abi); - sbuf_cat(newval, variable_string + strlen("${ABI}")); - sbuf_finish(newval); + asprintf(, "%.*s%s%s", + (int)(variable_string - oldval), oldval, abi, + variable_string + strlen("${ABI}")); + if (newval == NULL) + errx(EXIT_FAILURE, "asprintf"); free(c[PACKAGESITE].value); - c[PACKAGESITE].value = strdup(sbuf_data(newval)); + c[PACKAGESITE].value = newval; } static int ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"