From 2d832b2211fdb5b0e1d838839e5cddadd71eab95 Mon Sep 17 00:00:00 2001 From: ngie Date: Wed, 19 Jul 2017 19:53:07 +0000 Subject: [PATCH 01/49] cron(8) manpage updates - Document /etc/cron.d and /usr/local/etc/cron.d under FILES. - Reword documentation for -n: add appropriate soft-stop and remove contraction to appease igor. MFC after: 3 days --- usr.sbin/cron/cron/cron.8 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8 index 1bc04bd01944..5dc9595e0061 100644 --- a/usr.sbin/cron/cron/cron.8 +++ b/usr.sbin/cron/cron/cron.8 @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 31, 2016 +.Dd July 19, 2017 .Dt CRON 8 .Os .Sh NAME @@ -138,7 +138,7 @@ set to a null string, usually specified in a shell as or .Li \*q\*q . .It Fl n -Don't daemonize, run in foreground instead. +Do not daemonize; run in foreground instead. .It Fl s Enable special handling of situations when the GMT offset of the local timezone changes, such as the switches between the standard time and @@ -209,13 +209,17 @@ trace through the execution, but do not perform any actions .El .El .Sh FILES -.Bl -tag -width /etc/pam.d/cron -compact +.Bl -tag -width /usr/local/etc/cron.d -compact .It Pa /etc/crontab System crontab file +.It Pa /etc/cron.d +Directory for optional/modularized system crontab files. .It Pa /etc/pam.d/cron .Xr pam.conf 5 configuration file for .Nm +.It Pa /usr/local/etc/cron.d +Directory for third-party package provided crontab files. .It Pa /var/cron/tabs Directory for personal crontab files .El From f16b72a2cc8065ebf2ad6c511f9867472e8c61a3 Mon Sep 17 00:00:00 2001 From: kib Date: Wed, 19 Jul 2017 20:52:47 +0000 Subject: [PATCH 02/49] Add pctrie_init() and vm_radix_init() to initialize generic pctrie and vm_radix trie. Existing vm_radix_init() function is renamed to vm_radix_zinit(). Inlines moved out of the _ headers. Reviewed by: alc, markj (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D11661 --- sys/sys/_pctrie.h | 10 ---------- sys/sys/pctrie.h | 14 ++++++++++++++ sys/vm/_vm_radix.h | 10 ---------- sys/vm/vm_object.c | 4 ++-- sys/vm/vm_radix.c | 2 +- sys/vm/vm_radix.h | 16 +++++++++++++++- 6 files changed, 32 insertions(+), 24 deletions(-) diff --git a/sys/sys/_pctrie.h b/sys/sys/_pctrie.h index 45f69b20849c..c6d13baa992f 100644 --- a/sys/sys/_pctrie.h +++ b/sys/sys/_pctrie.h @@ -38,14 +38,4 @@ struct pctrie { uintptr_t pt_root; }; -#ifdef _KERNEL - -static __inline boolean_t -pctrie_is_empty(struct pctrie *ptree) -{ - - return (ptree->pt_root == 0); -} - -#endif /* _KERNEL */ #endif /* !__SYS_PCTRIE_H_ */ diff --git a/sys/sys/pctrie.h b/sys/sys/pctrie.h index f736877cc2b4..0c0af309b129 100644 --- a/sys/sys/pctrie.h +++ b/sys/sys/pctrie.h @@ -119,5 +119,19 @@ void pctrie_remove(struct pctrie *ptree, uint64_t key, size_t pctrie_node_size(void); int pctrie_zone_init(void *mem, int size, int flags); +static __inline void +pctrie_init(struct pctrie *ptree) +{ + + ptree->pt_root = 0; +} + +static __inline boolean_t +pctrie_is_empty(struct pctrie *ptree) +{ + + return (ptree->pt_root == 0); +} + #endif /* _KERNEL */ #endif /* !_SYS_PCTRIE_H_ */ diff --git a/sys/vm/_vm_radix.h b/sys/vm/_vm_radix.h index f06646240b2a..f061a5fefdee 100644 --- a/sys/vm/_vm_radix.h +++ b/sys/vm/_vm_radix.h @@ -38,14 +38,4 @@ struct vm_radix { uintptr_t rt_root; }; -#ifdef _KERNEL - -static __inline boolean_t -vm_radix_is_empty(struct vm_radix *rtree) -{ - - return (rtree->rt_root == 0); -} - -#endif /* _KERNEL */ #endif /* !__VM_RADIX_H_ */ diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index a751ac6ea2ff..6c6137d5fb22 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -204,7 +204,7 @@ vm_object_zinit(void *mem, int size, int flags) /* These are true for any object that has been freed */ object->type = OBJT_DEAD; object->ref_count = 0; - object->rtree.rt_root = 0; + vm_radix_init(&object->rtree); object->paging_in_progress = 0; object->resident_page_count = 0; object->shadow_count = 0; @@ -301,7 +301,7 @@ vm_object_init(void) #endif vm_object_zinit, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); - vm_radix_init(); + vm_radix_zinit(); } void diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index 4f0a57560ec9..1a19dd93af93 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -310,7 +310,7 @@ SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_THIRD, * Initialize the UMA slab zone. */ void -vm_radix_init(void) +vm_radix_zinit(void) { vm_radix_node_zone = uma_zcreate("RADIX NODE", diff --git a/sys/vm/vm_radix.h b/sys/vm/vm_radix.h index b8a722d20468..d96e50b01e48 100644 --- a/sys/vm/vm_radix.h +++ b/sys/vm/vm_radix.h @@ -35,7 +35,6 @@ #ifdef _KERNEL -void vm_radix_init(void); int vm_radix_insert(struct vm_radix *rtree, vm_page_t page); boolean_t vm_radix_is_singleton(struct vm_radix *rtree); vm_page_t vm_radix_lookup(struct vm_radix *rtree, vm_pindex_t index); @@ -44,6 +43,21 @@ vm_page_t vm_radix_lookup_le(struct vm_radix *rtree, vm_pindex_t index); void vm_radix_reclaim_allnodes(struct vm_radix *rtree); vm_page_t vm_radix_remove(struct vm_radix *rtree, vm_pindex_t index); vm_page_t vm_radix_replace(struct vm_radix *rtree, vm_page_t newpage); +void vm_radix_zinit(void); + +static __inline void +vm_radix_init(struct vm_radix *rtree) +{ + + rtree->rt_root = 0; +} + +static __inline boolean_t +vm_radix_is_empty(struct vm_radix *rtree) +{ + + return (rtree->rt_root == 0); +} #endif /* _KERNEL */ #endif /* !_VM_RADIX_H_ */ From f8f9fd1cf52cf161b6e14aff1582d8912c96265b Mon Sep 17 00:00:00 2001 From: rmacklem Date: Wed, 19 Jul 2017 20:57:41 +0000 Subject: [PATCH 03/49] Update the nfsv4 man page to reflect recent changes to support the newer RFCs (5661 and 7530). The main man changes are for the case of "numbers in strings" for user/groups that RFC7530 allows and avoids use of nfsuserd(8). This is a content change. Reviewed by: trasz (earlier version) MFC after: 1 week --- usr.sbin/nfsd/nfsv4.4 | 66 ++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/usr.sbin/nfsd/nfsv4.4 b/usr.sbin/nfsd/nfsv4.4 index 8d9bc809cbc5..82b25a2982b3 100644 --- a/usr.sbin/nfsd/nfsv4.4 +++ b/usr.sbin/nfsd/nfsv4.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 1, 2013 +.Dd July 19, 2017 .Dt NFSV4 4 .Os .Sh NAME @@ -34,7 +34,8 @@ The NFS client and server provides support for the .Tn NFSv4 specification; see -.%T "Network File System (NFS) Version 4 Protocol RFC 3530" . +.%T "Network File System (NFS) Version 4 Protocol RFC 7530" and +.%T "Network File System (NFS) Version 4 Minor Version 1 Protocol RFC 5661" . The protocol is somewhat similar to NFS Version 3, but differs in significant ways. It uses a single compound RPC that concatenates operations to-gether. @@ -74,6 +75,7 @@ It provides several optional features not present in NFS Version 3: - Referrals, which redirect subtrees to other servers (not yet implemented) - Delegations, which allow a client to operate on a file locally +- pNFS, where I/O operations are separated from Metadata operations .Ed .Pp The @@ -115,8 +117,8 @@ multiple server file systems, although not all clients are capable of doing this. .Pp .Nm -uses names for users and groups instead of numbers. -On the wire, they +uses strings for users and groups instead of numbers. +On the wire, these strings can either have the numbers in the string or take the form: .sp .Bd -literal -offset indent -compact @@ -136,15 +138,37 @@ Under FreeBSD, the mapping daemon is called .Xr nfsuserd 8 and has a command line option that overrides the domain component of the machine's hostname. -For use of +For use of this form of string on .Nm , either client or server, this daemon must be running. -If this ``'' is not set correctly or the daemon is not running, ``ls -l'' will typically +.Pp +The form where the numbers are in the strings can only be used for AUTH_SYS. +To configure your systems this way, the +.Xr nfsuserd 8 +daemon does not need to be running on the server, but the following sysctls need to be +set to 1 on the server. +.sp +.Bd -literal -offset indent -compact +vfs.nfs.enable_uidtostring +vfs.nfsd.enable_stringtouid +.Ed +.sp +On the client, the sysctl +.sp +.Bd -literal -offset indent -compact +vfs.nfs.enable_uidtostring +.Ed +.sp +must be set to 1 and the +.Xr nfsuserd 8 +daemon does not need to be running. +.Pp +If these strings are not configured correctly, ``ls -l'' will typically report a lot of ``nobody'' and ``nogroup'' ownerships. .Pp Although uid/gid numbers are no longer used in the .Nm -protocol, they will still be in the RPC authentication fields when +protocol except optionally in the above strings, they will still be in the RPC authentication fields when using AUTH_SYS (sec=sys), which is the default. As such, in this case both the user/group name and number spaces must be consistent between the client and server. @@ -156,24 +180,24 @@ will go on the wire. .Sh SERVER SETUP To set up the NFS server that supports .Nm , -you will need to either set the variables in +you will need to set the variables in .Xr rc.conf 5 as follows: .sp .Bd -literal -offset indent -compact nfs_server_enable="YES" nfsv4_server_enable="YES" +.Ed +.sp +plus +.sp +.Bd -literal -offset indent -compact nfsuserd_enable="YES" .Ed .sp -or start -.Xr mountd 8 -and -.Xr nfsd 8 -without the ``-o'' option, which would force use of the old server. -The -.Xr nfsuserd 8 -daemon must also be running. +if the server is using the ``@'' form of user/group strings or +is using the ``-manage-gids'' option for +.Xr nfsuserd 8 . .Pp You will also need to add at least one ``V4:'' line to the .Xr exports 5 @@ -232,7 +256,7 @@ plus set ``tcp'' and .Pp The .Xr nfsuserd 8 -must be running, as above. +must be running if name<->uid/gid mapping is being used, as above. Also, since an .Nm mount uses the host uuid to identify the client uniquely to the server, @@ -255,7 +279,7 @@ daemon to handle client side callbacks. This will occur if .sp .Bd -literal -offset indent -compact -nfsuserd_enable="YES" +nfsuserd_enable="YES" <-- If name<->uid/gid mapping is being used. nfscbd_enable="YES" .Ed .sp @@ -265,7 +289,7 @@ are set in Without a functioning callback path, a server will never issue Delegations to a client. .sp -By default, the callback address will be set to the IP address acquired via +For NFSv4.0, by default, the callback address will be set to the IP address acquired via rtalloc() in the kernel and port# 7745. To override the default port#, a command line option for .Xr nfscbd 8 @@ -282,6 +306,10 @@ N.N.N.N.N.N where the first 4 Ns are the host IP address and the last two are the port# in network byte order (all decimal #s in the range 0-255). .Pp +For NFSv4.1, the callback path (called a backchannel) uses the same TCP connection as the mount, +so none of the above applies and should work through gateways without +any issues. +.Pp To build a kernel with the client that supports .Nm linked into it, the option From 65d93b0e1a12136d82eeb751f397761130dcd8ff Mon Sep 17 00:00:00 2001 From: sbruno Date: Wed, 19 Jul 2017 21:18:04 +0000 Subject: [PATCH 04/49] Don't cache mbuf pointers if the number of descriptors is greater than the number of buffers. Submitted by: Matt Macy Sponsored by: Limelight Networks --- sys/net/iflib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 633ebc9668ba..2ec1dadef32c 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -2927,6 +2927,14 @@ iflib_busdma_load_mbuf_sg(iflib_txq_t txq, bus_dma_tag_t tag, bus_dmamap_t map, m_free(tmp); continue; } + m = m->m_next; + count++; + } while (m != NULL); + if (count > *nsegs) + return (0); + m = *m0; + count = 0; + do { next = (pidx + count) & (ntxd-1); MPASS(ifsd_m[next] == NULL); ifsd_m[next] = m; From bdfd94e586c6802af64144e877809a418c71755a Mon Sep 17 00:00:00 2001 From: brooks Date: Wed, 19 Jul 2017 22:06:35 +0000 Subject: [PATCH 05/49] Include ARCH_FLAGS in CFLAGS when building modules. Without this change, modules will match the default compiler configuration which may not be the same as the kernel values. Reviewed by: imp Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11633 --- sys/conf/kern.pre.mk | 1 + sys/conf/kmod.mk | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index d23d531ced64..e68eb7968218 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -216,6 +216,7 @@ MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH} MKMODULESENV+= MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} MKMODULESENV+= MODULES_EXTRA="${MODULES_EXTRA}" WITHOUT_MODULES="${WITHOUT_MODULES}" +MKMODULESENV+= ARCH_FLAGS="${ARCH_FLAGS}" .if (${KERN_IDENT} == LINT) MKMODULESENV+= ALL_MODULES=LINT .endif diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index da65f7117927..e2e63032ef19 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -366,7 +366,7 @@ ${_src}: .endif # Respect configuration-specific C flags. -CFLAGS+= ${CONF_CFLAGS} +CFLAGS+= ${ARCH_FLAGS} ${CONF_CFLAGS} .if !empty(SRCS:Mvnode_if.c) CLEANFILES+= vnode_if.c From da6df261b6bad6fc5ff171194390f9c3770371da Mon Sep 17 00:00:00 2001 From: sbruno Date: Wed, 19 Jul 2017 22:41:22 +0000 Subject: [PATCH 06/49] Restore igb(4) code dropped during iflib conversion - restore newer code for vf, i350, i210, i211 - restore dmac init code for i354 and i350 - restore WUC/WUFC update - check for igb mac type before attempting trying to assert a media changed event. - handle link events for igb(4) and em(4) devices differently and appropriately for their respective model types. Submitted by: Matt Macy Sponsored by: Limelight Networks --- sys/dev/e1000/if_em.c | 161 ++++++++++++++++++++++++++++++++++++++++-- sys/dev/e1000/if_em.h | 24 ++++++- 2 files changed, 178 insertions(+), 7 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index f25b9e055cbd..f0ee17879474 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -1025,7 +1025,7 @@ em_if_attach_post(if_ctx_t ctx) /* Non-AMT based hardware can now take control from firmware */ if (adapter->has_manage && !adapter->has_amt) em_get_hw_control(adapter); - + INIT_DEBUGOUT("em_if_attach_post: end"); return (error); @@ -1691,8 +1691,9 @@ em_if_update_admin_status(if_ctx_t ctx) struct e1000_hw *hw = &adapter->hw; struct ifnet *ifp = iflib_get_ifp(ctx); device_t dev = iflib_get_dev(ctx); - u32 link_check = 0; + u32 link_check, thstat, ctrl; + link_check = thstat = ctrl = 0; /* Get the cached link value or read phy for real */ switch (hw->phy.media_type) { case e1000_media_type_copper: @@ -1717,11 +1718,21 @@ em_if_update_admin_status(if_ctx_t ctx) e1000_check_for_link(hw); link_check = adapter->hw.mac.serdes_has_link; break; - default: + /* VF device is type_unknown */ case e1000_media_type_unknown: + e1000_check_for_link(hw); + link_check = !hw->mac.get_link_status; + /* Fall thru */ + default: break; } + /* Check for thermal downshift or shutdown */ + if (hw->mac.type == e1000_i350) { + thstat = E1000_READ_REG(hw, E1000_THSTAT); + ctrl = E1000_READ_REG(hw, E1000_CTRL_EXT); + } + /* Now check for a transition */ if (link_check && (adapter->link_active == 0)) { e1000_get_speed_and_duplex(hw, &adapter->link_speed, @@ -1743,6 +1754,21 @@ em_if_update_admin_status(if_ctx_t ctx) adapter->link_active = 1; adapter->smartspeed = 0; if_setbaudrate(ifp, adapter->link_speed * 1000000); + if ((ctrl & E1000_CTRL_EXT_LINK_MODE_GMII) && + (thstat & E1000_THSTAT_LINK_THROTTLE)) + device_printf(dev, "Link: thermal downshift\n"); + /* Delay Link Up for Phy update */ + if (((hw->mac.type == e1000_i210) || + (hw->mac.type == e1000_i211)) && + (hw->phy.id == I210_I_PHY_ID)) + msec_delay(I210_LINK_DELAY); + /* Reset if the media type changed. */ + if ((hw->dev_spec._82575.media_changed) && + (adapter->hw.mac.type >= igb_mac_min)) { + hw->dev_spec._82575.media_changed = false; + adapter->flags |= IGB_MEDIA_RESET; + em_reset(ctx); + } iflib_link_state_change(ctx, LINK_STATE_UP, ifp->if_baudrate); printf("Link state changed to up\n"); } else if (!link_check && (adapter->link_active == 1)) { @@ -2210,6 +2236,114 @@ lem_smartspeed(struct adapter *adapter) adapter->smartspeed = 0; } +/********************************************************************* + * + * Initialize the DMA Coalescing feature + * + **********************************************************************/ +static void +igb_init_dmac(struct adapter *adapter, u32 pba) +{ + device_t dev = adapter->dev; + struct e1000_hw *hw = &adapter->hw; + u32 dmac, reg = ~E1000_DMACR_DMAC_EN; + u16 hwm; + u16 max_frame_size; + + if (hw->mac.type == e1000_i211) + return; + + max_frame_size = adapter->shared->isc_max_frame_size; + if (hw->mac.type > e1000_82580) { + + if (adapter->dmac == 0) { /* Disabling it */ + E1000_WRITE_REG(hw, E1000_DMACR, reg); + return; + } else + device_printf(dev, "DMA Coalescing enabled\n"); + + /* Set starting threshold */ + E1000_WRITE_REG(hw, E1000_DMCTXTH, 0); + + hwm = 64 * pba - max_frame_size / 16; + if (hwm < 64 * (pba - 6)) + hwm = 64 * (pba - 6); + reg = E1000_READ_REG(hw, E1000_FCRTC); + reg &= ~E1000_FCRTC_RTH_COAL_MASK; + reg |= ((hwm << E1000_FCRTC_RTH_COAL_SHIFT) + & E1000_FCRTC_RTH_COAL_MASK); + E1000_WRITE_REG(hw, E1000_FCRTC, reg); + + + dmac = pba - max_frame_size / 512; + if (dmac < pba - 10) + dmac = pba - 10; + reg = E1000_READ_REG(hw, E1000_DMACR); + reg &= ~E1000_DMACR_DMACTHR_MASK; + reg = ((dmac << E1000_DMACR_DMACTHR_SHIFT) + & E1000_DMACR_DMACTHR_MASK); + + /* transition to L0x or L1 if available..*/ + reg |= (E1000_DMACR_DMAC_EN | E1000_DMACR_DMAC_LX_MASK); + + /* Check if status is 2.5Gb backplane connection + * before configuration of watchdog timer, which is + * in msec values in 12.8usec intervals + * watchdog timer= msec values in 32usec intervals + * for non 2.5Gb connection + */ + if (hw->mac.type == e1000_i354) { + int status = E1000_READ_REG(hw, E1000_STATUS); + if ((status & E1000_STATUS_2P5_SKU) && + (!(status & E1000_STATUS_2P5_SKU_OVER))) + reg |= ((adapter->dmac * 5) >> 6); + else + reg |= (adapter->dmac >> 5); + } else { + reg |= (adapter->dmac >> 5); + } + + E1000_WRITE_REG(hw, E1000_DMACR, reg); + + E1000_WRITE_REG(hw, E1000_DMCRTRH, 0); + + /* Set the interval before transition */ + reg = E1000_READ_REG(hw, E1000_DMCTLX); + if (hw->mac.type == e1000_i350) + reg |= IGB_DMCTLX_DCFLUSH_DIS; + /* + ** in 2.5Gb connection, TTLX unit is 0.4 usec + ** which is 0x4*2 = 0xA. But delay is still 4 usec + */ + if (hw->mac.type == e1000_i354) { + int status = E1000_READ_REG(hw, E1000_STATUS); + if ((status & E1000_STATUS_2P5_SKU) && + (!(status & E1000_STATUS_2P5_SKU_OVER))) + reg |= 0xA; + else + reg |= 0x4; + } else { + reg |= 0x4; + } + + E1000_WRITE_REG(hw, E1000_DMCTLX, reg); + + /* free space in tx packet buffer to wake from DMA coal */ + E1000_WRITE_REG(hw, E1000_DMCTXTH, (IGB_TXPBSIZE - + (2 * max_frame_size)) >> 6); + + /* make low power state decision controlled by DMA coal */ + reg = E1000_READ_REG(hw, E1000_PCIEMISC); + reg &= ~E1000_PCIEMISC_LX_DECISION; + E1000_WRITE_REG(hw, E1000_PCIEMISC, reg); + + } else if (hw->mac.type == e1000_82580) { + u32 reg = E1000_READ_REG(hw, E1000_PCIEMISC); + E1000_WRITE_REG(hw, E1000_PCIEMISC, + reg & ~E1000_PCIEMISC_LX_DECISION); + E1000_WRITE_REG(hw, E1000_DMACR, 0); + } +} static void em_reset(if_ctx_t ctx) @@ -2222,6 +2356,8 @@ em_reset(if_ctx_t ctx) u32 pba; INIT_DEBUGOUT("em_reset: begin"); + /* Let the firmware know the OS is in control */ + em_get_hw_control(adapter); /* Set up smart power down as default off on newer adapters. */ if (!em_smart_pwr_down && (hw->mac.type == e1000_82571 || @@ -2417,13 +2553,24 @@ em_reset(if_ctx_t ctx) /* Issue a global reset */ e1000_reset_hw(hw); - E1000_WRITE_REG(hw, E1000_WUFC, 0); - em_disable_aspm(adapter); + if (adapter->hw.mac.type >= igb_mac_min) { + E1000_WRITE_REG(hw, E1000_WUC, 0); + } else { + E1000_WRITE_REG(hw, E1000_WUFC, 0); + em_disable_aspm(adapter); + } + if (adapter->flags & IGB_MEDIA_RESET) { + e1000_setup_init_funcs(hw, TRUE); + e1000_get_bus_info(hw); + adapter->flags &= ~IGB_MEDIA_RESET; + } /* and a re-init */ if (e1000_init_hw(hw) < 0) { device_printf(dev, "Hardware Initialization Failed\n"); return; } + if (adapter->hw.mac.type >= igb_mac_min) + igb_init_dmac(adapter, pba); E1000_WRITE_REG(hw, E1000_VET, ETHERTYPE_VLAN); e1000_get_phy_info(hw); @@ -3307,6 +3454,9 @@ em_get_hw_control(struct adapter *adapter) { u32 ctrl_ext, swsm; + if (adapter->vf_ifp) + return; + if (adapter->hw.mac.type == e1000_82573) { swsm = E1000_READ_REG(&adapter->hw, E1000_SWSM); E1000_WRITE_REG(&adapter->hw, E1000_SWSM, @@ -3317,7 +3467,6 @@ em_get_hw_control(struct adapter *adapter) ctrl_ext = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT); E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD); - return; } /* diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 326de01058f0..e4386393a9b1 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -235,6 +235,27 @@ #define EM_EEPROM_APME 0x400; #define EM_82544_APME 0x0004; + +/* Support AutoMediaDetect for Marvell M88 PHY in i354 */ +#define IGB_MEDIA_RESET (1 << 0) + +/* Define the starting Interrupt rate per Queue */ +#define IGB_INTS_PER_SEC 8000 +#define IGB_DEFAULT_ITR ((1000000/IGB_INTS_PER_SEC) << 2) + +#define IGB_LINK_ITR 2000 +#define I210_LINK_DELAY 1000 + +#define IGB_MAX_SCATTER 40 +#define IGB_VFTA_SIZE 128 +#define IGB_BR_SIZE 4096 /* ring buf size */ +#define IGB_TSO_SIZE (65535 + sizeof(struct ether_vlan_header)) +#define IGB_TSO_SEG_SIZE 4096 /* Max dma segment size */ +#define IGB_TXPBSIZE 20408 +#define IGB_HDR_BUF 128 +#define IGB_PKTTYPE_MASK 0x0000FFF0 +#define IGB_DMCTLX_DCFLUSH_DIS 0x80000000 /* Disable DMA Coalesce Flush */ + /* * Driver state logic for the detection of a hung state * in hardware. Set TX_HUNG whenever a TX packet is used @@ -455,11 +476,11 @@ struct adapter { struct ifmedia *media; int msix; int if_flags; - int min_frame_size; int em_insert_vlan_header; u32 ims; bool in_detach; + u32 flags; /* Task for FAST handling */ struct grouptask link_task; @@ -514,6 +535,7 @@ struct adapter { unsigned long watchdog_events; struct e1000_hw_stats stats; + u16 vf_ifp; }; /******************************************************************************** From 6b75d5f10f3092cd77bd759d8469f618742492fb Mon Sep 17 00:00:00 2001 From: markj Date: Wed, 19 Jul 2017 23:34:28 +0000 Subject: [PATCH 07/49] Decode FreeBSD11 fstatat calls. --- usr.bin/truss/syscalls.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index ce9f5d07726c..24cf89183e5a 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -148,6 +148,9 @@ static struct syscall decoded_syscalls[] = { .args = { { Int, 0 } } }, { .name = "compat11.fstat", .ret_type = 1, .nargs = 2, .args = { { Int, 0 }, { Stat11 | OUT, 1 } } }, + { .name = "compat11.fstatat", .ret_type = 1, .nargs = 4, + .args = { { Atfd, 0 }, { Name | IN, 1 }, { Stat11 | OUT, 2 }, + { Atflags, 3 } } }, { .name = "compat11.lstat", .ret_type = 1, .nargs = 2, .args = { { Name | IN, 0 }, { Stat11 | OUT, 1 } } }, { .name = "compat11.stat", .ret_type = 1, .nargs = 2, From b9997cb3ae224169d30c1636f2973c72f492bc69 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 20 Jul 2017 00:40:03 +0000 Subject: [PATCH 08/49] Clean up leading whitespace (convert single column spaces to hard tabs) MFC after: now --- usr.sbin/newsyslog/tests/legacy_test.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/newsyslog/tests/legacy_test.sh b/usr.sbin/newsyslog/tests/legacy_test.sh index f8679132f772..24791ecda256 100644 --- a/usr.sbin/newsyslog/tests/legacy_test.sh +++ b/usr.sbin/newsyslog/tests/legacy_test.sh @@ -14,8 +14,8 @@ RFC3164_FMT='^[A-Z][a-z]{2} [ 0-9][0-9] [0-9]{2}:[0-9]{2}:[0-9]{2}' COUNT=0 TMPDIR=$(pwd)/work if [ $? -ne 0 ]; then - echo "$0: Can't create temp dir, exiting..." - exit 1 + echo "$0: Can't create temp dir, exiting..." + exit 1 fi # Begin an individual test @@ -432,8 +432,8 @@ tests_rfc5424() { cknt ${dir}${LOGFNAME}.0${ext} ckfe $LOGFNAME5424 cknt ${dir}${LOGFNAME5424}.0${ext} - ckrfc3164 ${LOGFNAME} - ckrfc5424 ${LOGFNAME5424} + ckrfc3164 ${LOGFNAME} + ckrfc5424 ${LOGFNAME5424} end begin "RFC-5424 - rotate normal 1 ${name_postfix}" @@ -442,10 +442,10 @@ tests_rfc5424() { ckfe ${dir}${LOGFNAME}.0${ext} ckfe $LOGFNAME5424 ckfe ${dir}${LOGFNAME5424}.0${ext} - ckrfc3164 ${LOGFNAME} - ckrfc3164 ${dir}${LOGFNAME}.0${ext} - ckrfc5424 ${LOGFNAME5424} - ckrfc5424 ${dir}${LOGFNAME5424}.0${ext} + ckrfc3164 ${LOGFNAME} + ckrfc3164 ${dir}${LOGFNAME}.0${ext} + ckrfc5424 ${LOGFNAME5424} + ckrfc5424 ${dir}${LOGFNAME5424}.0${ext} end tmpdir_clean From 4127dd6b50348062f74679dbb43008d0a2985a09 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 20 Jul 2017 04:32:06 +0000 Subject: [PATCH 09/49] Some trivial style(9) fixes - Delete trailing whitespace. - Fix leading indentation (convert single column spaces to tabs). - Convert "[Ff]all through" to "FALLTHROUGH", per implicit project style/spelling. Reviewed by: sbruno Differential Revision: D11665 --- sys/dev/e1000/if_em.c | 57 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index f0ee17879474..5202c4367a6f 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -203,7 +203,7 @@ static pci_vendor_info_t igb_vendor_info_array[] = PVID(0x8086, E1000_DEV_ID_I210_COPPER_OEM1, "Intel(R) PRO/1000 PCI-Express Network Driver"), PVID(0x8086, E1000_DEV_ID_I210_COPPER_FLASHLESS, "Intel(R) PRO/1000 PCI-Express Network Driver"), PVID(0x8086, E1000_DEV_ID_I210_SERDES_FLASHLESS, "Intel(R) PRO/1000 PCI-Express Network Driver"), - PVID(0x8086, E1000_DEV_ID_I210_FIBER, "Intel(R) PRO/1000 PCI-Express Network Driver"), + PVID(0x8086, E1000_DEV_ID_I210_FIBER, "Intel(R) PRO/1000 PCI-Express Network Driver"), PVID(0x8086, E1000_DEV_ID_I210_SERDES, "Intel(R) PRO/1000 PCI-Express Network Driver"), PVID(0x8086, E1000_DEV_ID_I210_SGMII, "Intel(R) PRO/1000 PCI-Express Network Driver"), PVID(0x8086, E1000_DEV_ID_I211_COPPER, "Intel(R) PRO/1000 PCI-Express Network Driver"), @@ -231,8 +231,8 @@ static int em_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs static void em_if_queues_free(if_ctx_t ctx); static uint64_t em_if_get_counter(if_ctx_t, ift_counter); -static void em_if_init(if_ctx_t ctx); -static void em_if_stop(if_ctx_t ctx); +static void em_if_init(if_ctx_t ctx); +static void em_if_stop(if_ctx_t ctx); static void em_if_media_status(if_ctx_t, struct ifmediareq *); static int em_if_media_change(if_ctx_t ctx); static int em_if_mtu_set(if_ctx_t ctx, uint32_t mtu); @@ -357,11 +357,11 @@ static device_method_t em_if_methods[] = { DEVMETHOD(ifdi_detach, em_if_detach), DEVMETHOD(ifdi_shutdown, em_if_shutdown), DEVMETHOD(ifdi_suspend, em_if_suspend), - DEVMETHOD(ifdi_resume, em_if_resume), + DEVMETHOD(ifdi_resume, em_if_resume), DEVMETHOD(ifdi_init, em_if_init), DEVMETHOD(ifdi_stop, em_if_stop), DEVMETHOD(ifdi_msix_intr_assign, em_if_msix_intr_assign), - DEVMETHOD(ifdi_intr_enable, em_if_enable_intr), + DEVMETHOD(ifdi_intr_enable, em_if_enable_intr), DEVMETHOD(ifdi_intr_disable, em_if_disable_intr), DEVMETHOD(ifdi_tx_queues_alloc, em_if_tx_queues_alloc), DEVMETHOD(ifdi_rx_queues_alloc, em_if_rx_queues_alloc), @@ -1401,7 +1401,7 @@ em_msix_link(void *arg) u32 reg_icr; ++adapter->link_irq; - MPASS(adapter->hw.back != NULL); + MPASS(adapter->hw.back != NULL); reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR); if (reg_icr & E1000_ICR_RXO) @@ -1720,9 +1720,9 @@ em_if_update_admin_status(if_ctx_t ctx) break; /* VF device is type_unknown */ case e1000_media_type_unknown: - e1000_check_for_link(hw); + e1000_check_for_link(hw); link_check = !hw->mac.get_link_status; - /* Fall thru */ + /* FALLTHROUGH */ default: break; } @@ -2536,15 +2536,15 @@ em_reset(if_ctx_t ctx) case e1000_vfadapt_i350: /* 16-byte granularity */ hw->fc.low_water = hw->fc.high_water - 16; - break; - case e1000_ich9lan: - case e1000_ich10lan: + break; + case e1000_ich9lan: + case e1000_ich10lan: if (if_getmtu(ifp) > ETHERMTU) { hw->fc.high_water = 0x2800; hw->fc.low_water = hw->fc.high_water - 8; break; } - /* else fall thru */ + /* FALLTHROUGH */ default: if (hw->mac.type == e1000_80003es2lan) hw->fc.pause_time = 0xFFFF; @@ -2611,7 +2611,7 @@ em_initialize_rss_mapping(struct adapter *adapter) for (i = 0; i < 32; ++i) E1000_WRITE_REG(hw, E1000_RETA(i), reta); - E1000_WRITE_REG(hw, E1000_MRQC, E1000_MRQC_RSS_ENABLE_2Q | + E1000_WRITE_REG(hw, E1000_MRQC, E1000_MRQC_RSS_ENABLE_2Q | E1000_MRQC_RSS_FIELD_IPV4_TCP | E1000_MRQC_RSS_FIELD_IPV4 | E1000_MRQC_RSS_FIELD_IPV6_TCP_EX | @@ -2698,8 +2698,7 @@ igb_initialize_rss_mapping(struct adapter *adapter) arc4rand(&rss_key, sizeof(rss_key), 0); #endif for (i = 0; i < 10; i++) - E1000_WRITE_REG_ARRAY(hw, - E1000_RSSRK(0), i, rss_key[i]); + E1000_WRITE_REG_ARRAY(hw, E1000_RSSRK(0), i, rss_key[i]); /* * Configure the RSS fields to hash upon. @@ -2766,7 +2765,7 @@ em_setup_interface(if_ctx_t ctx) /* Enable only WOL MAGIC by default */ if (adapter->wol) { if_setcapenablebit(ifp, IFCAP_WOL_MAGIC, - IFCAP_WOL_MCAST| IFCAP_WOL_UCAST); + IFCAP_WOL_MCAST| IFCAP_WOL_UCAST); } else { if_setcapenablebit(ifp, 0, IFCAP_WOL_MAGIC | IFCAP_WOL_MCAST| IFCAP_WOL_UCAST); @@ -2838,7 +2837,7 @@ em_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int ntxqs txr->tx_base = (struct e1000_tx_desc *)vaddrs[i*ntxqs]; txr->tx_paddr = paddrs[i*ntxqs]; } - + device_printf(iflib_get_dev(ctx), "allocated for %d tx_queues\n", adapter->tx_num_queues); return (0); fail: @@ -2863,7 +2862,7 @@ em_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, uint64_t *paddrs, int nrxqs adapter->rx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n"); error = ENOMEM; - goto fail; + goto fail; } for (i = 0, que = adapter->rx_queues; i < nrxqsets; i++, que++) { @@ -2903,7 +2902,7 @@ em_if_queues_free(if_ctx_t ctx) txr->tx_rsq = NULL; } free(adapter->tx_queues, M_DEVBUF); - adapter->tx_queues = NULL; + adapter->tx_queues = NULL; } if (rx_que != NULL) { @@ -3178,7 +3177,7 @@ em_initialize_receive_unit(if_ctx_t ctx) u64 bus_addr = rxr->rx_paddr; #if 0 u32 rdt = adapter->rx_num_queues -1; /* default */ -#endif +#endif E1000_WRITE_REG(hw, E1000_RDLEN(i), scctx->isc_nrxd[0] * sizeof(union e1000_rx_desc_extended)); @@ -3233,7 +3232,7 @@ em_initialize_receive_unit(if_ctx_t ctx) srrctl |= 2048 >> E1000_SRRCTL_BSIZEPKT_SHIFT; rctl |= E1000_RCTL_SZ_2048; } - + /* * If TX flow control is disabled and there's >1 queue defined, * enable DROP. @@ -3271,7 +3270,7 @@ em_initialize_receive_unit(if_ctx_t ctx) rxdctl &= 0xFFF00000; rxdctl |= IGB_RX_PTHRESH; rxdctl |= IGB_RX_HTHRESH << 8; - rxdctl |= IGB_RX_WTHRESH << 16; + rxdctl |= IGB_RX_WTHRESH << 16; E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl); } } else if (adapter->hw.mac.type >= e1000_pch2lan) { @@ -3400,7 +3399,7 @@ em_if_disable_intr(if_ctx_t ctx) /* * Bit of a misnomer, what this really means is * to enable OS management of the system... aka - * to disable special hardware management features + * to disable special hardware management features */ static void em_init_manageability(struct adapter *adapter) @@ -3786,7 +3785,7 @@ static void em_if_led_func(if_ctx_t ctx, int onoff) { struct adapter *adapter = iflib_get_softc(ctx); - + if (onoff) { e1000_setup_led(&adapter->hw); e1000_led_on(&adapter->hw); @@ -3932,7 +3931,7 @@ static uint64_t em_if_get_counter(if_ctx_t ctx, ift_counter cnt) { struct adapter *adapter = iflib_get_softc(ctx); - struct ifnet *ifp = iflib_get_ifp(ctx); + struct ifnet *ifp = iflib_get_ifp(ctx); switch (cnt) { case IFCOUNTER_COLLISIONS: @@ -3969,7 +3968,7 @@ static void em_add_hw_stats(struct adapter *adapter) { device_t dev = iflib_get_dev(adapter->ctx); - struct em_tx_queue *tx_que = adapter->tx_queues; + struct em_tx_queue *tx_que = adapter->tx_queues; struct em_rx_queue *rx_que = adapter->rx_queues; struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev); @@ -4214,7 +4213,7 @@ em_add_hw_stats(struct adapter *adapter) /* Interrupt Stats */ - int_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "interrupts", + int_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "interrupts", CTLFLAG_RD, NULL, "Interrupt Statistics"); int_list = SYSCTL_CHILDREN(int_node); @@ -4391,7 +4390,7 @@ em_set_flowcntl(SYSCTL_HANDLER_ARGS) case e1000_fc_none: adapter->hw.fc.requested_mode = input; adapter->fc = input; - break; + break; default: /* Do nothing */ return (error); @@ -4439,7 +4438,7 @@ em_sysctl_debug_info(SYSCTL_HANDLER_ARGS) if (result == 1) { adapter = (struct adapter *) arg1; em_print_debug_info(adapter); - } + } return (error); } From 437b34bbe2937cf79960dcdc83c1e5ad70f38215 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 20 Jul 2017 05:43:48 +0000 Subject: [PATCH 10/49] procstat(8): clarify program usage - Visualize mutually exclusive options and their corresponding arguments. - Try to make the subtleties that are expressed in the code, and potentially in the manpages, more apparent. --- usr.bin/procstat/procstat.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/usr.bin/procstat/procstat.c b/usr.bin/procstat/procstat.c index 24415dcf623a..375664119821 100644 --- a/usr.bin/procstat/procstat.c +++ b/usr.bin/procstat/procstat.c @@ -50,12 +50,23 @@ static void usage(void) { - xo_error("usage: procstat [--libxo] [-CHhn] [-M core] " + xo_error( + "usage: procstat [--libxo] [-Hhn] [-M core] " "[-N system] [-w interval]\n" - " [-b | -c | -e | -f | -i | -j | -k | " - "-l | -L | -r | -s | \n" - " -S | -t | -v | -x]\n" - " [-a | pid | core ...]\n"); + " [-S | -b | -c | -e | -i | -j | -k | -kk | " + "-l | -r | -s | \n" + " -t | -v | -x]\n" + " [-a | pid ... | core ...]\n" + " procstat [--libxo] -Cf [-hn] [-M core] " + "[-N system] [-a | pid ... | core ...]\n" + " [-S | -b | -c | -e | -i | -j | -k | -kk | " + "-l | -r | -s | \n" + " procstat [--libxo] -L [-hn] [-M core] " + "[-N system] [-w interval]\n" + " [-S | -b | -c | -e | -i | -j | -k | -kk | " + "-l | -r | -s | \n" + " -t | -v | -x]\n" + " [core ...]\n"); xo_finish(); exit(EX_USAGE); } From 1eb6bbbb6e52b8c3b637356529b7560d26d0a9f1 Mon Sep 17 00:00:00 2001 From: rlibby Date: Thu, 20 Jul 2017 06:47:06 +0000 Subject: [PATCH 11/49] efi: restrict visibility of EFIABI_ATTR-declared functions In-tree gcc (4.2) doesn't understand __attribute__((ms_abi)) (EFIABI_ATTR). Avoid declaring functions with that attribute when the compiler is detected to be gcc < 4.4. Reviewed by: kib, imp (previous version) Approved by: markj (mentor) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11636 --- sys/amd64/include/efi.h | 6 ++++++ sys/sys/efi.h | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/amd64/include/efi.h b/sys/amd64/include/efi.h index 272d5a8f3a83..a0a39b4056e9 100644 --- a/sys/amd64/include/efi.h +++ b/sys/amd64/include/efi.h @@ -36,8 +36,14 @@ * XXX: from gcc 6.2 manual: * Note, the ms_abi attribute for Microsoft Windows 64-bit targets * currently requires the -maccumulate-outgoing-args option. + * + * Avoid EFIABI_ATTR declarations for compilers that don't support it. + * GCC support began in version 4.4. */ +#if defined(__clang__) || defined(__GNUC__) && \ + (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4) #define EFIABI_ATTR __attribute__((ms_abi)) +#endif #ifdef _KERNEL struct uuid; diff --git a/sys/sys/efi.h b/sys/sys/efi.h index 68fc2816e494..05ccfab4908a 100644 --- a/sys/sys/efi.h +++ b/sys/sys/efi.h @@ -122,6 +122,9 @@ struct efi_tblhdr { uint32_t __res; }; +#ifdef _KERNEL + +#ifdef EFIABI_ATTR struct efi_rt { struct efi_tblhdr rt_hdr; efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *) @@ -144,6 +147,7 @@ struct efi_rt { efi_status (*rt_reset)(enum efi_reset, efi_status, u_long, efi_char *) EFIABI_ATTR; }; +#endif struct efi_systbl { struct efi_tblhdr st_hdr; @@ -163,7 +167,6 @@ struct efi_systbl { uint64_t st_cfgtbl; }; -#ifdef _KERNEL extern vm_paddr_t efi_systbl_phys; #endif /* _KERNEL */ From 4d77702aa0567b4d2bd81d13e1a98dc574ff4b5e Mon Sep 17 00:00:00 2001 From: sephe Date: Thu, 20 Jul 2017 07:13:26 +0000 Subject: [PATCH 12/49] hyperv/storvsc: Force SPC3 for CDROM attached. This unbreaks the CDROM attaching on GEN2 VMs. On GEN1 VMs, CDROM is attached to emulated ATA controller. PR: 220790 Submitted by: Hongjiang Zhang MFC after: 3 days Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D11634 --- .../hyperv/storvsc/hv_storvsc_drv_freebsd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c index 5b93554fdfdb..e687931637c9 100644 --- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c +++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c @@ -2209,6 +2209,23 @@ storvsc_io_done(struct hv_storvsc_request *reqp) resp_buf[0], resp_buf[1], resp_buf[2], resp_buf[3], resp_buf[4]); } + /* + * XXX: Hyper-V (since win2012r2) responses inquiry with + * unknown version (0) for GEN-2 DVD device. + * Manually set the version number to SPC3 in order to + * ask CAM to continue probing with "PROBE_REPORT_LUNS". + * see probedone() in scsi_xpt.c + */ + if (SID_TYPE(inq_data) == T_CDROM && + inq_data->version == 0 && + (vmstor_proto_version >= VMSTOR_PROTOCOL_VERSION_WIN8)) { + inq_data->version = SCSI_REV_SPC3; + if (bootverbose) { + xpt_print(ccb->ccb_h.path, + "set version from 0 to %d\n", + inq_data->version); + } + } /* * XXX: Manually fix the wrong response returned from WS2012 */ @@ -2218,7 +2235,7 @@ storvsc_io_done(struct hv_storvsc_request *reqp) vmstor_proto_version == VMSTOR_PROTOCOL_VERSION_WIN7)) { if (data_len >= 4 && (resp_buf[2] == 0 || resp_buf[3] == 0)) { - resp_buf[2] = 5; // verion=5 means SPC-3 + resp_buf[2] = SCSI_REV_SPC3; resp_buf[3] = 2; // resp fmt must be 2 if (bootverbose) xpt_print(ccb->ccb_h.path, From e79328a85fb413223b067b2b0b44cb7e16c4bbb5 Mon Sep 17 00:00:00 2001 From: tuexen Date: Thu, 20 Jul 2017 11:09:33 +0000 Subject: [PATCH 13/49] Fix the explicit EOR mode. If the final messages is not complete, send an ABORT. Joint work with rrs@ MFC after: 1 week --- sys/netinet/sctp_indata.c | 126 +++++++++++++++----------------- sys/netinet/sctp_ss_functions.c | 18 ++++- 2 files changed, 76 insertions(+), 68 deletions(-) diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index 2f5f3e0609ef..1f60ae1776ef 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -4293,47 +4293,44 @@ again: ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc))) { asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT; } + if (((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) || + (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) && + (asoc->stream_queue_cnt == 1) && + (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) { + struct mbuf *op_err; + + *abort_now = 1; + /* XXX */ + op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + return; + } if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) && (asoc->stream_queue_cnt == 0)) { - if (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT) { - /* Need to abort here */ - struct mbuf *op_err; + struct sctp_nets *netp; - abort_out_now: - *abort_now = 1; - /* XXX */ - op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); - return; - } else { - struct sctp_nets *netp; - - if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || - (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { - SCTP_STAT_DECR_GAUGE32(sctps_currestab); - } - SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); - SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); - sctp_stop_timers_for_shutdown(stcb); - if (asoc->alternate) { - netp = asoc->alternate; - } else { - netp = asoc->primary_destination; - } - sctp_send_shutdown(stcb, netp); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, - stcb->sctp_ep, stcb, netp); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, netp); + if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || + (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { + SCTP_STAT_DECR_GAUGE32(sctps_currestab); } + SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); + SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + if (asoc->alternate) { + netp = asoc->alternate; + } else { + netp = asoc->primary_destination; + } + sctp_send_shutdown(stcb, netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, + stcb->sctp_ep, stcb, netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, + stcb->sctp_ep, stcb, netp); } else if ((SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) && (asoc->stream_queue_cnt == 0)) { struct sctp_nets *netp; - if (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT) { - goto abort_out_now; - } SCTP_STAT_DECR_GAUGE32(sctps_currestab); SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); @@ -4989,48 +4986,45 @@ hopeless_peer: ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc))) { asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT; } + if (((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) || + (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) && + (asoc->stream_queue_cnt == 1) && + (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) { + struct mbuf *op_err; + + *abort_now = 1; + /* XXX */ + op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; + sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); + return; + } if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) && (asoc->stream_queue_cnt == 0)) { - if (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT) { - /* Need to abort here */ - struct mbuf *op_err; + struct sctp_nets *netp; - abort_out_now: - *abort_now = 1; - /* XXX */ - op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_31; - sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); - return; - } else { - struct sctp_nets *netp; - - if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || - (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { - SCTP_STAT_DECR_GAUGE32(sctps_currestab); - } - SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); - SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); - sctp_stop_timers_for_shutdown(stcb); - if (asoc->alternate) { - netp = asoc->alternate; - } else { - netp = asoc->primary_destination; - } - sctp_send_shutdown(stcb, netp); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, - stcb->sctp_ep, stcb, netp); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, netp); + if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) || + (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) { + SCTP_STAT_DECR_GAUGE32(sctps_currestab); } + SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT); + SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); + sctp_stop_timers_for_shutdown(stcb); + if (asoc->alternate) { + netp = asoc->alternate; + } else { + netp = asoc->primary_destination; + } + sctp_send_shutdown(stcb, netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, + stcb->sctp_ep, stcb, netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, + stcb->sctp_ep, stcb, netp); return; } else if ((SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) && (asoc->stream_queue_cnt == 0)) { struct sctp_nets *netp; - if (asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT) { - goto abort_out_now; - } SCTP_STAT_DECR_GAUGE32(sctps_currestab); SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT); SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING); diff --git a/sys/netinet/sctp_ss_functions.c b/sys/netinet/sctp_ss_functions.c index a5488b827516..22d3deb58fd9 100644 --- a/sys/netinet/sctp_ss_functions.c +++ b/sys/netinet/sctp_ss_functions.c @@ -268,9 +268,23 @@ sctp_ss_default_set_value(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_associa } static int -sctp_ss_default_is_user_msgs_incomplete(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_association *asoc SCTP_UNUSED) +sctp_ss_default_is_user_msgs_incomplete(struct sctp_tcb *stcb SCTP_UNUSED, struct sctp_association *asoc) { - return (0); + struct sctp_stream_out *strq; + struct sctp_stream_queue_pending *sp; + + if (asoc->stream_queue_cnt != 1) { + return (0); + } + strq = asoc->ss_data.locked_on_sending; + if (strq == NULL) { + return (0); + } + sp = TAILQ_FIRST(&strq->outqueue); + if (sp == NULL) { + return (0); + } + return (!sp->msg_is_complete); } /* From 0c018c8ab740a29e2589c6bb2107eb401477fef9 Mon Sep 17 00:00:00 2001 From: tuexen Date: Thu, 20 Jul 2017 14:50:13 +0000 Subject: [PATCH 14/49] Deal with listening socket correctly. --- sys/netinet/sctp_os_bsd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index 1251dfc7eef0..9afd8592da5c 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -392,8 +392,8 @@ typedef struct callout sctp_os_timer_t; (sb).sb_mb = NULL; \ (sb).sb_mbcnt = 0; -#define SCTP_SB_LIMIT_RCV(so) so->so_rcv.sb_hiwat -#define SCTP_SB_LIMIT_SND(so) so->so_snd.sb_hiwat +#define SCTP_SB_LIMIT_RCV(so) (SOLISTENING(so) ? so->sol_sbrcv_hiwat : so->so_rcv.sb_hiwat) +#define SCTP_SB_LIMIT_SND(so) (SOLISTENING(so) ? so->sol_sbsnd_hiwat : so->so_snd.sb_hiwat) /* * routes, output, etc. From d5e1936733c18be53772b1f3a16b1f387cfc0569 Mon Sep 17 00:00:00 2001 From: emaste Date: Thu, 20 Jul 2017 15:28:48 +0000 Subject: [PATCH 15/49] date: avoid crash on invalid time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit localtime(3) returns NULL when passed an invalid time_t but date(1) previously did not handle it. Exit with an error in that case. PR: 220828 Reported by: Vinícius Zavam Reviewed by: cem, kevans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D11660 --- bin/date/date.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/date/date.c b/bin/date/date.c index 79ef2253a6e7..7f2e1b28a64c 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -85,7 +85,7 @@ main(int argc, char *argv[]) int set_timezone; struct vary *v; const struct vary *badv; - struct tm lt; + struct tm *lt; struct stat sb; v = NULL; @@ -174,8 +174,10 @@ main(int argc, char *argv[]) if (*argv && **argv == '+') format = *argv + 1; - lt = *localtime(&tval); - badv = vary_apply(v, <); + lt = localtime(&tval); + if (lt == NULL) + errx(1, "invalid time"); + badv = vary_apply(v, lt); if (badv) { fprintf(stderr, "%s: Cannot apply date adjustment\n", badv->arg); @@ -191,7 +193,7 @@ main(int argc, char *argv[]) */ setlocale(LC_TIME, "C"); - (void)strftime(buf, sizeof(buf), format, <); + (void)strftime(buf, sizeof(buf), format, lt); (void)printf("%s\n", buf); if (fflush(stdout)) err(1, "stdout"); @@ -210,6 +212,8 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) int century; lt = localtime(&tval); + if (lt == NULL) + errx(1, "invalid time"); lt->tm_isdst = -1; /* divine correct DST */ if (fmt != NULL) { From 8a3defd6c6f2c9b32a68ee1d3aca8344febf06fa Mon Sep 17 00:00:00 2001 From: emaste Date: Thu, 20 Jul 2017 15:52:36 +0000 Subject: [PATCH 16/49] acpidump: use C99 designated initializers Submitted by: Guangyuan Yang Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D11659 --- usr.sbin/acpi/acpidump/acpi.c | 36 ++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 9b6a76983d92..b1b4e2c68b3f 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -392,16 +392,25 @@ acpi_print_local_nmi(u_int lint, uint16_t mps_flags) acpi_print_mps_flags(mps_flags); } -static const char *apic_types[] = { "Local APIC", "IO APIC", "INT Override", - "NMI", "Local APIC NMI", - "Local APIC Override", "IO SAPIC", - "Local SAPIC", "Platform Interrupt", - "Local X2APIC", "Local X2APIC NMI", - "GIC CPU Interface Structure", - "GIC Distributor Structure", - "GICv2m MSI Frame", - "GIC Redistributor Structure", - "GIC ITS Structure" }; +static const char *apic_types[] = { + [ACPI_MADT_TYPE_LOCAL_APIC] = "Local APIC", + [ACPI_MADT_TYPE_IO_APIC] = "IO APIC", + [ACPI_MADT_TYPE_INTERRUPT_OVERRIDE] = "INT Override", + [ACPI_MADT_TYPE_NMI_SOURCE] = "NMI", + [ACPI_MADT_TYPE_LOCAL_APIC_NMI] = "Local APIC NMI", + [ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE] = "Local APIC Override", + [ACPI_MADT_TYPE_IO_SAPIC] = "IO SAPIC", + [ACPI_MADT_TYPE_LOCAL_SAPIC] = "Local SAPIC", + [ACPI_MADT_TYPE_INTERRUPT_SOURCE] = "Platform Interrupt", + [ACPI_MADT_TYPE_LOCAL_X2APIC] = "Local X2APIC", + [ACPI_MADT_TYPE_LOCAL_X2APIC_NMI] = "Local X2APIC NMI", + [ACPI_MADT_TYPE_GENERIC_INTERRUPT] = "GIC CPU Interface Structure", + [ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR] = "GIC Distributor Structure", + [ACPI_MADT_TYPE_GENERIC_MSI_FRAME] = "GICv2m MSI Frame", + [ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR] = "GIC Redistributor Structure", + [ACPI_MADT_TYPE_GENERIC_TRANSLATOR] = "GIC ITS Structure" +}; + static const char *platform_int_types[] = { "0 (unknown)", "PMI", "INIT", "Corrected Platform Error" }; @@ -1076,7 +1085,12 @@ acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp) printf("\tProximity Domain=%d\n", mp->ProximityDomain); } -static const char *srat_types[] = { "CPU", "Memory", "X2APIC", "GICC" }; +static const char *srat_types[] = { + [ACPI_SRAT_TYPE_CPU_AFFINITY] = "CPU", + [ACPI_SRAT_TYPE_MEMORY_AFFINITY] = "Memory", + [ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY] = "X2APIC", + [ACPI_SRAT_TYPE_GICC_AFFINITY] = "GICC" +}; static void acpi_print_srat(ACPI_SUBTABLE_HEADER *srat) From f303bf47a3546eeba032ce50b9f289101f0c734c Mon Sep 17 00:00:00 2001 From: asomers Date: Thu, 20 Jul 2017 16:24:29 +0000 Subject: [PATCH 17/49] Remove some private symbols from librt Private functions like __aio_read and _aio_read were exposed in FBSDprivate_1.0 by r169090, even though they've never been used outside of librt. Also, remove some weak references from r156136 that have never resolved. Reviewed by: kib MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11649 --- lib/libc/sys/Symbol.map | 9 --------- lib/librt/Symbol.map | 10 ---------- lib/librt/aio.c | 5 ----- 3 files changed, 24 deletions(-) diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 4411cfe968cd..0d9cdfab3e70 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -469,21 +469,13 @@ FBSDprivate_1.0 { __sys_acct; _adjtime; __sys_adjtime; - _aio_cancel; __sys_aio_cancel; - _aio_error; __sys_aio_error; - _aio_fsync; __sys_aio_fsync; - _aio_read; __sys_aio_read; - _aio_return; __sys_aio_return; - _aio_suspend; __sys_aio_suspend; - _aio_waitcomplete; __sys_aio_waitcomplete; - _aio_write; __sys_aio_write; _audit; __sys_audit; @@ -727,7 +719,6 @@ FBSDprivate_1.0 { __sys_lgetfh; _link; __sys_link; - _lio_listio; __sys_lio_listio; _listen; __sys_listen; diff --git a/lib/librt/Symbol.map b/lib/librt/Symbol.map index fef3c1557941..a4a88b947070 100644 --- a/lib/librt/Symbol.map +++ b/lib/librt/Symbol.map @@ -31,16 +31,6 @@ FBSD_1.5 { }; FBSDprivate_1.0 { - _aio_read; - _aio_write; - _aio_return; - _aio_waitcomplete; - _aio_fsync; - __aio_read; - __aio_write; - __aio_return; - __aio_waitcomplete; - __aio_fsync; _mq_open; _mq_close; _mq_notify; diff --git a/lib/librt/aio.c b/lib/librt/aio.c index fe4a118a3a2b..af88cf3affdd 100644 --- a/lib/librt/aio.c +++ b/lib/librt/aio.c @@ -39,15 +39,10 @@ #include "sigev_thread.h" #include "un-namespace.h" -__weak_reference(__aio_read, _aio_read); __weak_reference(__aio_read, aio_read); -__weak_reference(__aio_write, _aio_write); __weak_reference(__aio_write, aio_write); -__weak_reference(__aio_return, _aio_return); __weak_reference(__aio_return, aio_return); -__weak_reference(__aio_waitcomplete, _aio_waitcomplete); __weak_reference(__aio_waitcomplete, aio_waitcomplete); -__weak_reference(__aio_fsync, _aio_fsync); __weak_reference(__aio_fsync, aio_fsync); typedef void (*aio_func)(union sigval val, struct aiocb *iocb); From cb4e3a42a1653311dd13f11d531abd0378a37271 Mon Sep 17 00:00:00 2001 From: emaste Date: Thu, 20 Jul 2017 17:31:27 +0000 Subject: [PATCH 18/49] acpidump: add ACPI NFIT (NVDIMM Firmware Interface Table) Submitted by: Guangyuan Yang MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D11479 --- usr.sbin/acpi/acpidump/acpi.c | 196 ++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index b1b4e2c68b3f..4d7edad053c5 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "acpidump.h" @@ -70,6 +71,8 @@ static void acpi_print_srat_memory(ACPI_SRAT_MEM_AFFINITY *mp); static void acpi_print_srat(ACPI_SUBTABLE_HEADER *srat); static void acpi_handle_srat(ACPI_TABLE_HEADER *sdp); static void acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp); +static void acpi_print_nfit(ACPI_NFIT_HEADER *nfit); +static void acpi_handle_nfit(ACPI_TABLE_HEADER *sdp); static void acpi_print_sdt(ACPI_TABLE_HEADER *sdp); static void acpi_print_fadt(ACPI_TABLE_HEADER *sdp); static void acpi_print_facs(ACPI_TABLE_FACS *facs); @@ -79,6 +82,8 @@ static void acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp); static void acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp); static void acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, void (*action)(ACPI_SUBTABLE_HEADER *)); +static void acpi_walk_nfit(ACPI_TABLE_HEADER *table, void *first, + void (*action)(ACPI_NFIT_HEADER *)); /* Size of an address. 32-bit for ACPI 1.0, 64-bit for ACPI 2.0 and up. */ static int addr_size; @@ -280,6 +285,27 @@ acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, } } +static void +acpi_walk_nfit(ACPI_TABLE_HEADER *table, void *first, + void (*action)(ACPI_NFIT_HEADER *)) +{ + ACPI_NFIT_HEADER *subtable; + char *end; + + subtable = first; + end = (char *)table + table->Length; + while ((char *)subtable < end) { + printf("\n"); + if (subtable->Length < sizeof(ACPI_NFIT_HEADER)) { + warnx("invalid subtable length %u", subtable->Length); + return; + } + action(subtable); + subtable = (ACPI_NFIT_HEADER *)((char *)subtable + + subtable->Length); + } +} + static void acpi_print_cpu(u_char cpu_id) { @@ -1141,6 +1167,174 @@ acpi_handle_srat(ACPI_TABLE_HEADER *sdp) printf(END_COMMENT); } +static const char *nfit_types[] = { + [ACPI_NFIT_TYPE_SYSTEM_ADDRESS] = "System Address", + [ACPI_NFIT_TYPE_MEMORY_MAP] = "Memory Map", + [ACPI_NFIT_TYPE_INTERLEAVE] = "Interleave", + [ACPI_NFIT_TYPE_SMBIOS] = "SMBIOS", + [ACPI_NFIT_TYPE_CONTROL_REGION] = "Control Region", + [ACPI_NFIT_TYPE_DATA_REGION] = "Data Region", + [ACPI_NFIT_TYPE_FLUSH_ADDRESS] = "Flush Address" +}; + + +static void +acpi_print_nfit(ACPI_NFIT_HEADER *nfit) +{ + char *uuidstr; + uint32_t status; + + ACPI_NFIT_SYSTEM_ADDRESS *sysaddr; + ACPI_NFIT_MEMORY_MAP *mmap; + ACPI_NFIT_INTERLEAVE *ileave; + ACPI_NFIT_SMBIOS *smbios; + ACPI_NFIT_CONTROL_REGION *ctlreg; + ACPI_NFIT_DATA_REGION *datareg; + ACPI_NFIT_FLUSH_ADDRESS *fladdr; + + if (nfit->Type < nitems(nfit_types)) + printf("\tType=%s\n", nfit_types[nfit->Type]); + else + printf("\tType=%u (unknown)\n", nfit->Type); + switch (nfit->Type) { + case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: + sysaddr = (ACPI_NFIT_SYSTEM_ADDRESS *)nfit; + printf("\tRangeIndex=%u\n", (u_int)sysaddr->RangeIndex); + printf("\tProximityDomain=%u\n", + (u_int)sysaddr->ProximityDomain); + uuid_to_string((uuid_t *)(sysaddr->RangeGuid), + &uuidstr, &status); + if (status != uuid_s_ok) + errx(1, "uuid_to_string: status=%u", status); + printf("\tRangeGuid=%s\n", uuidstr); + free(uuidstr); + printf("\tAddress=0x%016jx\n", (uintmax_t)sysaddr->Address); + printf("\tLength=0x%016jx\n", (uintmax_t)sysaddr->Length); + printf("\tMemoryMapping=0x%016jx\n", + (uintmax_t)sysaddr->MemoryMapping); + +#define PRINTFLAG(var, flag) printflag((var), ACPI_NFIT_## flag, #flag) + + printf("\tFlags="); + PRINTFLAG(sysaddr->Flags, ADD_ONLINE_ONLY); + PRINTFLAG(sysaddr->Flags, PROXIMITY_VALID); + PRINTFLAG_END(); + +#undef PRINTFLAG + + break; + case ACPI_NFIT_TYPE_MEMORY_MAP: + mmap = (ACPI_NFIT_MEMORY_MAP *)nfit; + printf("\tDeviceHandle=%u\n", (u_int)mmap->DeviceHandle); + printf("\tPhysicalId=%u\n", (u_int)mmap->PhysicalId); + printf("\tRegionId=%u\n", (u_int)mmap->RegionId); + printf("\tRangeIndex=%u\n", (u_int)mmap->RangeIndex); + printf("\tRegionIndex=%u\n", (u_int)mmap->RegionIndex); + printf("\tRegionSize=0x%016jx\n", (uintmax_t)mmap->RegionSize); + printf("\tRegionOffset=0x%016jx\n", + (uintmax_t)mmap->RegionOffset); + printf("\tAddress=0x%016jx\n", (uintmax_t)mmap->Address); + printf("\tInterleaveIndex=%u\n", (u_int)mmap->InterleaveIndex); + +#define PRINTFLAG(var, flag) printflag((var), ACPI_NFIT_MEM_## flag, #flag) + + printf("\tFlags="); + PRINTFLAG(mmap->Flags, SAVE_FAILED); + PRINTFLAG(mmap->Flags, RESTORE_FAILED); + PRINTFLAG(mmap->Flags, FLUSH_FAILED); + PRINTFLAG(mmap->Flags, NOT_ARMED); + PRINTFLAG(mmap->Flags, HEALTH_OBSERVED); + PRINTFLAG(mmap->Flags, HEALTH_ENABLED); + PRINTFLAG(mmap->Flags, MAP_FAILED); + PRINTFLAG_END(); + +#undef PRINTFLAG + + break; + case ACPI_NFIT_TYPE_INTERLEAVE: + ileave = (ACPI_NFIT_INTERLEAVE *)nfit; + printf("\tInterleaveIndex=%u\n", + (u_int)ileave->InterleaveIndex); + printf("\tLineCount=%u\n", (u_int)ileave->LineCount); + printf("\tLineSize=%u\n", (u_int)ileave->LineSize); + /* XXX ileave->LineOffset[i] output is not supported */ + break; + case ACPI_NFIT_TYPE_SMBIOS: + smbios = (ACPI_NFIT_SMBIOS *)nfit; + /* XXX smbios->Data[x] output is not supported */ + break; + case ACPI_NFIT_TYPE_CONTROL_REGION: + ctlreg = (ACPI_NFIT_CONTROL_REGION *)nfit; + printf("\tRegionIndex=%u\n", (u_int)ctlreg->RegionIndex); + printf("\tVendorId=0x%04x\n", (u_int)ctlreg->VendorId); + printf("\tDeviceId=0x%04x\n", (u_int)ctlreg->DeviceId); + printf("\tRevisionId=%u\n", (u_int)ctlreg->RevisionId); + printf("\tSubsystemVendorId=0x%04x\n", + (u_int)ctlreg->SubsystemVendorId); + printf("\tSubsystemDeviceId=0x%04x\n", + (u_int)ctlreg->SubsystemDeviceId); + printf("\tSubsystemRevisionId=%u\n", + (u_int)ctlreg->SubsystemRevisionId); + printf("\tValidFields=%u\n", (u_int)ctlreg->ValidFields); + printf("\tManufacturingLocation=%u\n", + (u_int)ctlreg->ManufacturingLocation); + printf("\tManufacturingDate=%u\n", + (u_int)ctlreg->ManufacturingDate); + printf("\tSerialNumber=%u\n", + (u_int)ctlreg->SerialNumber); + printf("\tWindows=%u\n", (u_int)ctlreg->Windows); + printf("\tWindowSize=0x%016jx\n", + (uintmax_t)ctlreg->WindowSize); + printf("\tCommandOffset=0x%016jx\n", + (uintmax_t)ctlreg->CommandOffset); + printf("\tCommandSize=0x%016jx\n", + (uintmax_t)ctlreg->CommandSize); + printf("\tStatusOffset=0x%016jx\n", + (uintmax_t)ctlreg->StatusOffset); + printf("\tStatusSize=0x%016jx\n", + (uintmax_t)ctlreg->StatusSize); + +#define PRINTFLAG(var, flag) printflag((var), ACPI_NFIT_## flag, #flag) + + printf("\tFlags="); + PRINTFLAG(mmap->Flags, ADD_ONLINE_ONLY); + PRINTFLAG(mmap->Flags, PROXIMITY_VALID); + PRINTFLAG_END(); + +#undef PRINTFLAG + + break; + case ACPI_NFIT_TYPE_DATA_REGION: + datareg = (ACPI_NFIT_DATA_REGION *)nfit; + printf("\tRegionIndex=%u\n", (u_int)datareg->RegionIndex); + printf("\tWindows=%u\n", (u_int)datareg->Windows); + printf("\tOffset=0x%016jx\n", (uintmax_t)datareg->Offset); + printf("\tSize=0x%016jx\n", (uintmax_t)datareg->Size); + printf("\tCapacity=0x%016jx\n", (uintmax_t)datareg->Capacity); + printf("\tStartAddress=0x%016jx\n", + (uintmax_t)datareg->StartAddress); + break; + case ACPI_NFIT_TYPE_FLUSH_ADDRESS: + fladdr = (ACPI_NFIT_FLUSH_ADDRESS *)nfit; + printf("\tDeviceHandle=%u\n", (u_int)fladdr->DeviceHandle); + printf("\tHintCount=%u\n", (u_int)fladdr->HintCount); + /* XXX fladdr->HintAddress[i] output is not supported */ + break; + } +} + +static void +acpi_handle_nfit(ACPI_TABLE_HEADER *sdp) +{ + ACPI_TABLE_NFIT *nfit; + + printf(BEGIN_COMMENT); + acpi_print_sdt(sdp); + nfit = (ACPI_TABLE_NFIT *)sdp; + acpi_walk_nfit(sdp, (nfit + 1), acpi_print_nfit); + printf(END_COMMENT); +} + static void acpi_print_sdt(ACPI_TABLE_HEADER *sdp) { @@ -1456,6 +1650,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) acpi_handle_tcpa(sdp); else if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4)) acpi_handle_dmar(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4)) + acpi_handle_nfit(sdp); else { printf(BEGIN_COMMENT); acpi_print_sdt(sdp); From ba275e50260a80acd086254532ece8206452d5bc Mon Sep 17 00:00:00 2001 From: emaste Date: Thu, 20 Jul 2017 17:36:17 +0000 Subject: [PATCH 19/49] acpidump: add GIC ITS srat type From ACPI 6.2, 5.2.16.5 MFC after: 1 week Sponsored by: The FreeBSD Foundation --- usr.sbin/acpi/acpidump/acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 4d7edad053c5..5e4b7b2ddac9 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -1115,7 +1115,8 @@ static const char *srat_types[] = { [ACPI_SRAT_TYPE_CPU_AFFINITY] = "CPU", [ACPI_SRAT_TYPE_MEMORY_AFFINITY] = "Memory", [ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY] = "X2APIC", - [ACPI_SRAT_TYPE_GICC_AFFINITY] = "GICC" + [ACPI_SRAT_TYPE_GICC_AFFINITY] = "GICC", + [ACPI_SRAT_TYPE_GIC_ITS_AFFINITY] = "GIC ITS", }; static void From 2a0eda5e75c759be8681596baab9e6ebdda1dbc9 Mon Sep 17 00:00:00 2001 From: mjoras Date: Thu, 20 Jul 2017 18:14:27 +0000 Subject: [PATCH 20/49] Add myself and mentor line to committers-src.dot. Approved by: rstone (mentor) Differential Revision: https://reviews.freebsd.org/D11672 --- share/misc/committers-src.dot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot index 75775ae3cafc..fe75e66f46b5 100644 --- a/share/misc/committers-src.dot +++ b/share/misc/committers-src.dot @@ -244,6 +244,7 @@ melifaro [label="Alexander V. Chernikov\nmelifaro@FreeBSD.org\n2011/10/04"] mizhka [label="Michael Zhilin\nmizhka@FreeBSD.org\n2016/07/19"] mjacob [label="Matt Jacob\nmjacob@FreeBSD.org\n1997/08/13"] mjg [label="Mateusz Guzik\nmjg@FreeBSD.org\n2012/06/04"] +mjoras [label="Matt Joras\nmjoras@FreeBSD.org\n2017/07/12"] mlaier [label="Max Laier\nmlaier@FreeBSD.org\n2004/02/10"] mmel [label="Michal Meloun\nmmel@FreeBSD.org\n2015/11/01"] monthadar [label="Monthadar Al Jaberi\nmonthadar@FreeBSD.org\n2012/04/02"] @@ -720,6 +721,7 @@ rrs -> jchandra rrs -> tuexen rstone -> markj +rstone -> mjoras ru -> ceri ru -> cjc From e937346d82a894a391841091d9b1ce2931c58387 Mon Sep 17 00:00:00 2001 From: emaste Date: Thu, 20 Jul 2017 18:22:49 +0000 Subject: [PATCH 21/49] add arm64 objcopy output target for embedfs PR: 220877 Submitted by: David NewHamlet MFC after: 1 week --- sys/conf/kern.pre.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index e68eb7968218..036a84e5f558 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -251,6 +251,7 @@ EMBEDFS_ARCH.${MACHINE_ARCH}!= sed -n '/OUTPUT_ARCH/s/.*(\(.*\)).*/\1/p' ${LDSCR EMBEDFS_FORMAT.arm?= elf32-littlearm EMBEDFS_FORMAT.armv6?= elf32-littlearm +EMBEDFS_FORMAT.aarch64?= elf64-littleaarch64 EMBEDFS_FORMAT.mips?= elf32-tradbigmips EMBEDFS_FORMAT.mipsel?= elf32-tradlittlemips EMBEDFS_FORMAT.mips64?= elf64-tradbigmips From cd4342efe56c4a1e158095d2493ce90738298909 Mon Sep 17 00:00:00 2001 From: dim Date: Thu, 20 Jul 2017 20:27:19 +0000 Subject: [PATCH 22/49] Fix printf format warning in zfs_module.c Clang 5.0.0 got better warnings about print format strings using %zd, and this leads to the following -Werror warning on e.g. arm: sys/boot/efi/boot1/zfs_module.c:186:18: error: format specifies type 'ssize_t' (aka 'int') but the argument has type 'off_t' (aka 'long long') [-Werror,-Wformat] "(%lu)\n", st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); ^~~~~~~~~~ Fix this by casting off_t arguments to intmax_t, and using %jd instead. Reviewed by: tsoome MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D11678 --- sys/boot/efi/boot1/zfs_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/boot/efi/boot1/zfs_module.c b/sys/boot/efi/boot1/zfs_module.c index 363ae342a82f..bf861ccaaf73 100644 --- a/sys/boot/efi/boot1/zfs_module.c +++ b/sys/boot/efi/boot1/zfs_module.c @@ -182,8 +182,8 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize) if ((status = bs->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf)) != EFI_SUCCESS) { - printf("Failed to allocate load buffer %zd for pool '%s' for '%s' " - "(%lu)\n", st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); + printf("Failed to allocate load buffer %jd for pool '%s' for '%s' " + "(%lu)\n", (intmax_t)st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); return (EFI_INVALID_PARAMETER); } From 3c2763f8464452f0b377b91a8f90c7c83996e0ad Mon Sep 17 00:00:00 2001 From: dim Date: Thu, 20 Jul 2017 20:28:31 +0000 Subject: [PATCH 23/49] Fix printf format warning in iflib.c Clang 5.0.0 got better warnings about printf format strings using %zd, and this leads to the following -Werror warning on e.g. arm: sys/net/iflib.c:1517:8: error: format specifies type 'ssize_t' (aka 'int') but the argument has type 'bus_size_t' (aka 'unsigned long') [-Werror,-Wformat] sctx->isc_tx_maxsize, nsegments, sctx->isc_tx_maxsegsize); ^~~~~~~~~~~~~~~~~~~~ sys/net/iflib.c:1517:41: error: format specifies type 'ssize_t' (aka 'int') but the argument has type 'bus_size_t' (aka 'unsigned long') [-Werror,-Wformat] sctx->isc_tx_maxsize, nsegments, sctx->isc_tx_maxsegsize); ^~~~~~~~~~~~~~~~~~~~~~~ Fix this by casting bus_size_t arguments to uintmax_t, and using %ju instead. Reviewed by: emaste MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D11679 --- sys/net/iflib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 2ec1dadef32c..910bc2b680fd 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -1513,8 +1513,8 @@ iflib_txsd_alloc(iflib_txq_t txq) NULL, /* lockfuncarg */ &txq->ift_desc_tag))) { device_printf(dev,"Unable to allocate TX DMA tag: %d\n", err); - device_printf(dev,"maxsize: %zd nsegments: %d maxsegsize: %zd\n", - sctx->isc_tx_maxsize, nsegments, sctx->isc_tx_maxsegsize); + device_printf(dev,"maxsize: %ju nsegments: %d maxsegsize: %ju\n", + (uintmax_t)sctx->isc_tx_maxsize, nsegments, (uintmax_t)sctx->isc_tx_maxsegsize); goto fail; } if ((err = bus_dma_tag_create(bus_get_dma_tag(dev), From 3359d0c4fa6b0a95f8fce4caa6fa53f014021909 Mon Sep 17 00:00:00 2001 From: rmacklem Date: Thu, 20 Jul 2017 23:15:50 +0000 Subject: [PATCH 24/49] r320062 introduced a bug when doing NFSv4.1 mounts against some non-FreeBSD servers. r320062 used nm_rsize, nm_wsize to set the maximum request/response sizes for the NFSv4.1 session. If rsize,wsize are not specified as options, the value of nm_rsize, nm_wsize is 0 at session creation, resulting in values for request/response that are too small. This patch fixes the problem. A workaround is to specify rsize=N,wsize=N mount options explicitly, so they are set before session creation. This bug only affects NFSv4.1 mounts against some non-FreeBSD servers. MFC after: 1 week --- sys/fs/nfsclient/nfs_clrpcops.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 23cc47f5c69c..c135f3254f6c 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -4672,8 +4672,14 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsclsession *sep, uint32_t crflags, maxval, *tl; struct nfsrv_descript nfsd; struct nfsrv_descript *nd = &nfsd; - int error, irdcnt; + int error, irdcnt, rsiz, wsiz; + rsiz = nmp->nm_rsize; + if (rsiz == 0) + rsiz = NFS_MAXBSIZE; + wsiz = nmp->nm_wsize; + if (wsiz == 0) + wsiz = NFS_MAXBSIZE; nfscl_reqstart(nd, NFSPROC_CREATESESSION, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED); *tl++ = sep->nfsess_clientid.lval[0]; @@ -4687,8 +4693,8 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsclsession *sep, /* Fill in fore channel attributes. */ NFSM_BUILD(tl, uint32_t *, 7 * NFSX_UNSIGNED); *tl++ = 0; /* Header pad size */ - *tl++ = txdr_unsigned(nmp->nm_wsize + NFS_MAXXDR);/* Max request size */ - *tl++ = txdr_unsigned(nmp->nm_rsize + NFS_MAXXDR);/* Max reply size */ + *tl++ = txdr_unsigned(wsiz + NFS_MAXXDR);/* Max request size */ + *tl++ = txdr_unsigned(rsiz + NFS_MAXXDR);/* Max reply size */ *tl++ = txdr_unsigned(4096); /* Max response size cached */ *tl++ = txdr_unsigned(20); /* Max operations */ *tl++ = txdr_unsigned(64); /* Max slots */ From a6315c2c10bc4d71a21f75a9c94350beb43a51ee Mon Sep 17 00:00:00 2001 From: rmacklem Date: Thu, 20 Jul 2017 23:59:47 +0000 Subject: [PATCH 25/49] Revert r321308. I'll commit a better fix soon. --- sys/fs/nfsclient/nfs_clrpcops.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index c135f3254f6c..23cc47f5c69c 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -4672,14 +4672,8 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsclsession *sep, uint32_t crflags, maxval, *tl; struct nfsrv_descript nfsd; struct nfsrv_descript *nd = &nfsd; - int error, irdcnt, rsiz, wsiz; + int error, irdcnt; - rsiz = nmp->nm_rsize; - if (rsiz == 0) - rsiz = NFS_MAXBSIZE; - wsiz = nmp->nm_wsize; - if (wsiz == 0) - wsiz = NFS_MAXBSIZE; nfscl_reqstart(nd, NFSPROC_CREATESESSION, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED); *tl++ = sep->nfsess_clientid.lval[0]; @@ -4693,8 +4687,8 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsclsession *sep, /* Fill in fore channel attributes. */ NFSM_BUILD(tl, uint32_t *, 7 * NFSX_UNSIGNED); *tl++ = 0; /* Header pad size */ - *tl++ = txdr_unsigned(wsiz + NFS_MAXXDR);/* Max request size */ - *tl++ = txdr_unsigned(rsiz + NFS_MAXXDR);/* Max reply size */ + *tl++ = txdr_unsigned(nmp->nm_wsize + NFS_MAXXDR);/* Max request size */ + *tl++ = txdr_unsigned(nmp->nm_rsize + NFS_MAXXDR);/* Max reply size */ *tl++ = txdr_unsigned(4096); /* Max response size cached */ *tl++ = txdr_unsigned(20); /* Max operations */ *tl++ = txdr_unsigned(64); /* Max slots */ From 4f0e3fa213d7f9ad393d7923ad5c6dafe74ff99f Mon Sep 17 00:00:00 2001 From: rmacklem Date: Fri, 21 Jul 2017 00:14:43 +0000 Subject: [PATCH 26/49] r320062 introduced a bug when doing NFSv4.1 mounts against some non-FreeBSD servers. r320062 used nm_rsize, nm_wsize to set the maximum request/response sizes for the NFSv4.1 session. If rsize,wsize are not specified as options, the value of nm_rsize, nm_wsize is 0 at session creation, resulting in values for request/response that are too small. This patch fixes the problem. A workaround is to specify rsize=N,wsize=N mount options explicitly, so they are set before session creation. This bug only affects NFSv4.1 mounts against some non-FreeBSD servers. MFC after: 1 week --- sys/fs/nfsclient/nfs_clrpcops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 23cc47f5c69c..c76f20e2507e 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -4674,6 +4674,11 @@ nfsrpc_createsession(struct nfsmount *nmp, struct nfsclsession *sep, struct nfsrv_descript *nd = &nfsd; int error, irdcnt; + /* Make sure nm_rsize, nm_wsize is set. */ + if (nmp->nm_rsize > NFS_MAXBSIZE || nmp->nm_rsize == 0) + nmp->nm_rsize = NFS_MAXBSIZE; + if (nmp->nm_wsize > NFS_MAXBSIZE || nmp->nm_wsize == 0) + nmp->nm_wsize = NFS_MAXBSIZE; nfscl_reqstart(nd, NFSPROC_CREATESESSION, nmp, NULL, 0, NULL, NULL); NFSM_BUILD(tl, uint32_t *, 4 * NFSX_UNSIGNED); *tl++ = sep->nfsess_clientid.lval[0]; From d255ed42067f2d7b7b82e1e522291c7fdb1ad89e Mon Sep 17 00:00:00 2001 From: kevans Date: Fri, 21 Jul 2017 01:35:55 +0000 Subject: [PATCH 27/49] Add regression test for recent regex(3) breakage BREs recently became prematurely sensitive to the branching operator, which outright broke expressions that used it instead of failing silently. Test that \| is matching a literal | for the time being. Reviewed by: cem, emaste, ngie Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D11577 --- contrib/netbsd-tests/lib/libc/regex/data/subexp.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/netbsd-tests/lib/libc/regex/data/subexp.in b/contrib/netbsd-tests/lib/libc/regex/data/subexp.in index c7bcc06175ea..d3efe2eab270 100644 --- a/contrib/netbsd-tests/lib/libc/regex/data/subexp.in +++ b/contrib/netbsd-tests/lib/libc/regex/data/subexp.in @@ -11,6 +11,9 @@ a(b+)c - abc abc b a(b+)c - abbbc abbbc bbb a(b*)c - ac ac @c (a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de +# Begin FreeBSD +a\(b\|c\)d b ab|cd ab|cd b|c +# End FreeBSD # the regression tester only asks for 9 subexpressions a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k From 5742973cc87d34d9cceb72774014ba3d8e9cb1a2 Mon Sep 17 00:00:00 2001 From: loos Date: Fri, 21 Jul 2017 03:04:55 +0000 Subject: [PATCH 28/49] Fix a couple of typos in a comment. MFC after: 1 week Sponsored by: Rubicon Communications, LLC (Netgate) --- sys/netpfil/ipfw/ip_fw_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c index 305ca7322657..d3723e58ba3d 100644 --- a/sys/netpfil/ipfw/ip_fw_table.c +++ b/sys/netpfil/ipfw/ip_fw_table.c @@ -1658,7 +1658,7 @@ ipfw_unref_table(struct ip_fw_chain *ch, uint16_t kidx) } /* - * Lookup an arbtrary key @paddr of legth @plen in table @tbl. + * Lookup an arbitrary key @paddr of length @plen in table @tbl. * Stores found value in @val. * * Returns 1 if key was found. From 8080cd3d5c95800a5e7f94c0cfd61cb0b128e2db Mon Sep 17 00:00:00 2001 From: loos Date: Fri, 21 Jul 2017 03:28:35 +0000 Subject: [PATCH 29/49] Do not allow the use of the loopback interface in netmap. The generic support in netmap send the packets using if_transmit() and the loopback do not support packets coming from if_transmit()/if_start(). This avoids the use of the loopback interface and the subsequent crash that happens when the application send packets to the loopback interface. Details in: https://github.com/luigirizzo/netmap/issues/322 Reported by: Vincenzo Maffione Sponsored by: Rubicon Communications, LLC (Netgate) --- sys/dev/netmap/netmap_generic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c index aea1b6109626..30f83a920825 100644 --- a/sys/dev/netmap/netmap_generic.c +++ b/sys/dev/netmap/netmap_generic.c @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); #include /* sockaddrs */ #include #include +#include #include #include /* bus_dmamap_* in netmap_kern.h */ @@ -1198,6 +1199,13 @@ generic_netmap_attach(struct ifnet *ifp) int retval; u_int num_tx_desc, num_rx_desc; +#ifdef __FreeBSD__ + if (ifp->if_type == IFT_LOOP) { + D("if_loop is not supported by %s", __func__); + return EINVAL; + } +#endif + num_tx_desc = num_rx_desc = netmap_generic_ringsize; /* starting point */ nm_os_generic_find_num_desc(ifp, &num_tx_desc, &num_rx_desc); /* ignore errors */ From f2d8ef6f2623a0382b90162f3328228e5c43a115 Mon Sep 17 00:00:00 2001 From: jhibbits Date: Fri, 21 Jul 2017 03:40:05 +0000 Subject: [PATCH 30/49] Add cpufreq support for P1022 and MPC8536 P1022 and MPC8536 include a 'jog' feature for clock control (jog being a slower form of run mode). This is done by changing the PLL multiplier, and cannot be done if any core is in doze or sleep mode. --- sys/conf/files.powerpc | 1 + sys/powerpc/cpufreq/mpc85xx_jog.c | 343 ++++++++++++++++++++++++++++++ 2 files changed, 344 insertions(+) create mode 100644 sys/powerpc/cpufreq/mpc85xx_jog.c diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index a733fa50dfeb..d7be355d3ea2 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -118,6 +118,7 @@ powerpc/booke/platform_bare.c optional booke powerpc/booke/pmap.c optional booke powerpc/booke/spe.c optional powerpcspe powerpc/cpufreq/dfs.c optional cpufreq +powerpc/cpufreq/mpc85xx_jog.c optional cpufreq mpc85xx powerpc/cpufreq/pcr.c optional cpufreq aim powerpc/cpufreq/pmufreq.c optional cpufreq aim pmu powerpc/fpu/fpu_add.c optional fpu_emu diff --git a/sys/powerpc/cpufreq/mpc85xx_jog.c b/sys/powerpc/cpufreq/mpc85xx_jog.c new file mode 100644 index 000000000000..bb37889567f2 --- /dev/null +++ b/sys/powerpc/cpufreq/mpc85xx_jog.c @@ -0,0 +1,343 @@ +/*- + * Copyright (c) 2017 Justin Hibbits + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include "cpufreq_if.h" + +/* No worries about uint32_t math overflow in here, because the highest + * multiplier supported is 4, and the highest speed part is still well below + * 2GHz. + */ + +#define GUTS_PORPLLSR (CCSRBAR_VA + 0xe0000) +#define GUTS_PMJCR (CCSRBAR_VA + 0xe007c) +#define PMJCR_RATIO_M 0x3f +#define PMJCR_CORE_MULT(x,y) ((x) << (16 + ((y) * 8))) +#define PMJCR_GET_CORE_MULT(x,y) (((x) >> (16 + ((y) * 8))) & 0x3f) +#define GUTS_POWMGTCSR (CCSRBAR_VA + 0xe0080) +#define POWMGTCSR_JOG 0x00200000 +#define POWMGTCSR_INT_MASK 0x00000f00 + +#define MHZ 1000000 + +struct mpc85xx_jog_softc { + device_t dev; + int cpu; + int low; + int high; + int min_freq; +}; + +static struct ofw_compat_data *mpc85xx_jog_devcompat(void); +static void mpc85xx_jog_identify(driver_t *driver, device_t parent); +static int mpc85xx_jog_probe(device_t dev); +static int mpc85xx_jog_attach(device_t dev); +static int mpc85xx_jog_settings(device_t dev, struct cf_setting *sets, int *count); +static int mpc85xx_jog_set(device_t dev, const struct cf_setting *set); +static int mpc85xx_jog_get(device_t dev, struct cf_setting *set); +static int mpc85xx_jog_type(device_t dev, int *type); + +static device_method_t mpc85xx_jog_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, mpc85xx_jog_identify), + DEVMETHOD(device_probe, mpc85xx_jog_probe), + DEVMETHOD(device_attach, mpc85xx_jog_attach), + + /* cpufreq interface */ + DEVMETHOD(cpufreq_drv_set, mpc85xx_jog_set), + DEVMETHOD(cpufreq_drv_get, mpc85xx_jog_get), + DEVMETHOD(cpufreq_drv_type, mpc85xx_jog_type), + DEVMETHOD(cpufreq_drv_settings, mpc85xx_jog_settings), + + {0, 0} +}; + +static driver_t mpc85xx_jog_driver = { + "jog", + mpc85xx_jog_methods, + sizeof(struct mpc85xx_jog_softc) +}; + +static devclass_t mpc85xx_jog_devclass; +DRIVER_MODULE(mpc85xx_jog, cpu, mpc85xx_jog_driver, mpc85xx_jog_devclass, 0, 0); + +struct mpc85xx_constraints { + int threshold; /* Threshold frequency, in MHz, for setting CORE_SPD bit. */ + int min_mult; /* Minimum PLL multiplier. */ +}; + +static struct mpc85xx_constraints mpc8536_constraints = { + 800, + 3 +}; + +static struct mpc85xx_constraints p1022_constraints = { + 500, + 2 +}; + +static struct ofw_compat_data jog_compat[] = { + {"fsl,mpc8536-guts", (uintptr_t)&mpc8536_constraints}, + {"fsl,p1022-guts", (uintptr_t)&p1022_constraints}, + {NULL, 0} +}; + +static struct ofw_compat_data * +mpc85xx_jog_devcompat() +{ + phandle_t node; + int i; + + node = OF_finddevice("/soc"); + if (node <= 0) + return (NULL); + + for (i = 0; jog_compat[i].ocd_str != NULL; i++) + if (ofw_bus_find_compatible(node, jog_compat[i].ocd_str) > 0) + break; + + if (jog_compat[i].ocd_str == NULL) + return (NULL); + + return (&jog_compat[i]); +} + +static void +mpc85xx_jog_identify(driver_t *driver, device_t parent) +{ + struct ofw_compat_data *compat; + + /* Make sure we're not being doubly invoked. */ + if (device_find_child(parent, "mpc85xx_jog", -1) != NULL) + return; + + compat = mpc85xx_jog_devcompat(); + if (compat == NULL) + return; + + /* + * We attach a child for every CPU since settings need to + * be performed on every CPU in the SMP case. + */ + if (BUS_ADD_CHILD(parent, 10, "jog", -1) == NULL) + device_printf(parent, "add jog child failed\n"); +} + +static int +mpc85xx_jog_probe(device_t dev) +{ + struct ofw_compat_data *compat; + + compat = mpc85xx_jog_devcompat(); + if (compat == NULL || compat->ocd_str == NULL) + return (ENXIO); + + device_set_desc(dev, "Freescale CPU Jogger"); + return (0); +} + +static int +mpc85xx_jog_attach(device_t dev) +{ + struct ofw_compat_data *compat; + struct mpc85xx_jog_softc *sc; + struct mpc85xx_constraints *constraints; + phandle_t cpu; + uint32_t reg; + + sc = device_get_softc(dev); + sc->dev = dev; + + compat = mpc85xx_jog_devcompat(); + constraints = (struct mpc85xx_constraints *)compat->ocd_data; + cpu = ofw_bus_get_node(device_get_parent(dev)); + + if (cpu <= 0) { + device_printf(dev,"No CPU device tree node!\n"); + return (ENXIO); + } + + OF_getencprop(cpu, "reg", &sc->cpu, sizeof(sc->cpu)); + + reg = ccsr_read4(GUTS_PORPLLSR); + + /* + * Assume power-on PLL is the highest PLL config supported on the + * board. + */ + sc->high = PMJCR_GET_CORE_MULT(reg, sc->cpu); + sc->min_freq = constraints->threshold; + sc->low = constraints->min_mult; + + cpufreq_register(dev); + return (0); +} + +static int +mpc85xx_jog_settings(device_t dev, struct cf_setting *sets, int *count) +{ + struct mpc85xx_jog_softc *sc; + uint32_t sysclk; + int i; + + sc = device_get_softc(dev); + if (sets == NULL || count == NULL) + return (EINVAL); + if (*count < sc->high - 1) + return (E2BIG); + + sysclk = mpc85xx_get_system_clock(); + /* Return a list of valid settings for this driver. */ + memset(sets, CPUFREQ_VAL_UNKNOWN, sizeof(*sets) * sc->high); + + for (i = sc->high; i >= sc->low; --i) { + sets[sc->high - i].freq = sysclk * i / MHZ; + sets[sc->high - i].dev = dev; + sets[sc->high - i].spec[0] = i; + } + *count = sc->high - sc->low + 1; + + return (0); +} + +struct jog_rv_args { + int cpu; + int mult; + int slow; + volatile int inprogress; +}; + +static void +mpc85xx_jog_set_int(void *arg) +{ + struct jog_rv_args *args = arg; + uint32_t reg; + + if (PCPU_GET(cpuid) == args->cpu) { + reg = ccsr_read4(GUTS_PMJCR); + reg &= ~PMJCR_CORE_MULT(PMJCR_RATIO_M, args->cpu); + reg |= PMJCR_CORE_MULT(args->mult, args->cpu); + if (args->slow) + reg &= ~(1 << (12 + args->cpu)); + else + reg |= (1 << (12 + args->cpu)); + + ccsr_write4(GUTS_PMJCR, reg); + + reg = ccsr_read4(GUTS_POWMGTCSR); + reg |= POWMGTCSR_JOG | POWMGTCSR_INT_MASK; + ccsr_write4(GUTS_POWMGTCSR, reg); + + /* Wait for completion */ + do { + DELAY(100); + reg = ccsr_read4(GUTS_POWMGTCSR); + } while (reg & POWMGTCSR_JOG); + + reg = ccsr_read4(GUTS_POWMGTCSR); + ccsr_write4(GUTS_POWMGTCSR, reg & ~POWMGTCSR_INT_MASK); + ccsr_read4(GUTS_POWMGTCSR); + + args->inprogress = 0; + } else { + while (args->inprogress) + cpu_spinwait(); + } +} + +static int +mpc85xx_jog_set(device_t dev, const struct cf_setting *set) +{ + struct mpc85xx_jog_softc *sc; + struct jog_rv_args args; + + if (set == NULL) + return (EINVAL); + + sc = device_get_softc(dev); + + args.slow = (set->freq <= sc->min_freq); + args.mult = set->spec[0]; + args.cpu = PCPU_GET(cpuid); + args.inprogress = 1; + smp_rendezvous(smp_no_rendezvous_barrier, mpc85xx_jog_set_int, + smp_no_rendezvous_barrier, &args); + + return (0); +} + +static int +mpc85xx_jog_get(device_t dev, struct cf_setting *set) +{ + struct mpc85xx_jog_softc *sc; + uint32_t pmjcr; + uint32_t freq; + + if (set == NULL) + return (EINVAL); + + sc = device_get_softc(dev); + memset(set, CPUFREQ_VAL_UNKNOWN, sizeof(*set)); + + pmjcr = ccsr_read4(GUTS_PORPLLSR); + freq = PMJCR_GET_CORE_MULT(pmjcr, sc->cpu); + freq *= mpc85xx_get_system_clock(); + freq /= MHZ; + + set->freq = freq; + set->dev = dev; + + return (0); +} + +static int +mpc85xx_jog_type(device_t dev, int *type) +{ + + if (type == NULL) + return (EINVAL); + + *type = CPUFREQ_TYPE_ABSOLUTE; + return (0); +} + From 17be7892ad85882dfb57e55fe0741fa5c374aede Mon Sep 17 00:00:00 2001 From: loos Date: Fri, 21 Jul 2017 03:42:09 +0000 Subject: [PATCH 31/49] Update netmap_user.h with the current version of netmap. This file should have been committed together with r319881. MFC after: 1 week MFC with: r319881 Pointy hat to: loos --- sys/net/netmap_user.h | 46 ++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/sys/net/netmap_user.h b/sys/net/netmap_user.h index 4fbf38731d33..758084c1dcc1 100644 --- a/sys/net/netmap_user.h +++ b/sys/net/netmap_user.h @@ -309,16 +309,16 @@ typedef void (*nm_cb_t)(u_char *, const struct nm_pkthdr *, const u_char *d); * ifname (netmap:foo or vale:foo) is the port name * a suffix can indicate the follwing: * ^ bind the host (sw) ring pair - * * bind host and NIC ring pairs (transparent) + * * bind host and NIC ring pairs * -NN bind individual NIC ring pair * {NN bind master side of pipe NN * }NN bind slave side of pipe NN * a suffix starting with / and the following flags, * in any order: * x exclusive access - * z zero copy monitor - * t monitor tx side - * r monitor rx side + * z zero copy monitor (both tx and rx) + * t monitor tx side (copy monitor) + * r monitor rx side (copy monitor) * R bind only RX ring(s) * T bind only TX ring(s) * @@ -634,9 +634,10 @@ nm_open(const char *ifname, const struct nmreq *req, const char *vpname = NULL; #define MAXERRMSG 80 char errmsg[MAXERRMSG] = ""; - enum { P_START, P_RNGSFXOK, P_GETNUM, P_FLAGS, P_FLAGSOK } p_state; + enum { P_START, P_RNGSFXOK, P_GETNUM, P_FLAGS, P_FLAGSOK, P_MEMID } p_state; int is_vale; long num; + uint16_t nr_arg2 = 0; if (strncmp(ifname, "netmap:", 7) && strncmp(ifname, NM_BDG_NAME, strlen(NM_BDG_NAME))) { @@ -665,7 +666,7 @@ nm_open(const char *ifname, const struct nmreq *req, } /* scan for a separator */ - for (; *port && !index("-*^{}/", *port); port++) + for (; *port && !index("-*^{}/@", *port); port++) ; if (is_vale && !nm_is_identifier(vpname, port)) { @@ -707,6 +708,9 @@ nm_open(const char *ifname, const struct nmreq *req, case '/': /* start of flags */ p_state = P_FLAGS; break; + case '@': /* start of memid */ + p_state = P_MEMID; + break; default: snprintf(errmsg, MAXERRMSG, "unknown modifier: '%c'", *port); goto fail; @@ -718,6 +722,9 @@ nm_open(const char *ifname, const struct nmreq *req, case '/': p_state = P_FLAGS; break; + case '@': + p_state = P_MEMID; + break; default: snprintf(errmsg, MAXERRMSG, "unexpected character: '%c'", *port); goto fail; @@ -736,6 +743,11 @@ nm_open(const char *ifname, const struct nmreq *req, break; case P_FLAGS: case P_FLAGSOK: + if (*port == '@') { + port++; + p_state = P_MEMID; + break; + } switch (*port) { case 'x': nr_flags |= NR_EXCLUSIVE; @@ -762,17 +774,25 @@ nm_open(const char *ifname, const struct nmreq *req, port++; p_state = P_FLAGSOK; break; + case P_MEMID: + if (nr_arg2 != 0) { + snprintf(errmsg, MAXERRMSG, "double setting of memid"); + goto fail; + } + num = strtol(port, (char **)&port, 10); + if (num <= 0) { + snprintf(errmsg, MAXERRMSG, "invalid memid %ld, must be >0", num); + goto fail; + } + nr_arg2 = num; + p_state = P_RNGSFXOK; + break; } } if (p_state != P_START && p_state != P_RNGSFXOK && p_state != P_FLAGSOK) { snprintf(errmsg, MAXERRMSG, "unexpected end of port name"); goto fail; } - if ((nr_flags & NR_ZCOPY_MON) && - !(nr_flags & (NR_MONITOR_TX|NR_MONITOR_RX))) { - snprintf(errmsg, MAXERRMSG, "'z' used but neither 'r', nor 't' found"); - goto fail; - } ND("flags: %s %s %s %s", (nr_flags & NR_EXCLUSIVE) ? "EXCLUSIVE" : "", (nr_flags & NR_ZCOPY_MON) ? "ZCOPY_MON" : "", @@ -799,6 +819,8 @@ nm_open(const char *ifname, const struct nmreq *req, /* these fields are overridden by ifname and flags processing */ d->req.nr_ringid |= nr_ringid; d->req.nr_flags |= nr_flags; + if (nr_arg2) + d->req.nr_arg2 = nr_arg2; memcpy(d->req.nr_name, ifname, namelen); d->req.nr_name[namelen] = '\0'; /* optionally import info from parent */ @@ -848,7 +870,7 @@ nm_open(const char *ifname, const struct nmreq *req, nr_reg = d->req.nr_flags & NR_REG_MASK; - if (nr_reg == NR_REG_SW) { /* host stack */ + if (nr_reg == NR_REG_SW) { /* host stack */ d->first_tx_ring = d->last_tx_ring = d->req.nr_tx_rings; d->first_rx_ring = d->last_rx_ring = d->req.nr_rx_rings; } else if (nr_reg == NR_REG_ALL_NIC) { /* only nic */ From 9489f69692d46f9a30028ffd68daba7fca96e57e Mon Sep 17 00:00:00 2001 From: jhibbits Date: Fri, 21 Jul 2017 03:48:09 +0000 Subject: [PATCH 32/49] Compile the atomic64 emulation for powerpcspe With this, ZFS builds for and runs (not quite stablely) on powerpcspe. --- sys/conf/files.powerpc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index d7be355d3ea2..e6a3d367fd2e 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -15,7 +15,7 @@ font.h optional sc \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" # # There is only an asm version on ppc64. -cddl/compat/opensolaris/kern/opensolaris_atomic.c optional zfs powerpc | dtrace powerpc compile-with "${ZFS_C}" +cddl/compat/opensolaris/kern/opensolaris_atomic.c optional zfs powerpc | dtrace powerpc | zfs powerpcspe | dtrace powerpcspe compile-with "${ZFS_C}" cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S optional zfs powerpc64 | dtrace powerpc64 compile-with "${ZFS_S}" cddl/dev/dtrace/powerpc/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/powerpc/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" From a5d4ca7b37afa42699a3d77d0f614802000a9c89 Mon Sep 17 00:00:00 2001 From: loos Date: Fri, 21 Jul 2017 03:59:56 +0000 Subject: [PATCH 33/49] Restore the changes done in r313982: Replace zero with NULL for pointers. Spotted by: Harry Schmalzbauer MFC after: 1 week Sponsored by: Rubicon Communications, LLC (Netgate) --- sys/dev/netmap/netmap_freebsd.c | 2 +- sys/dev/netmap/netmap_mem2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 4a684e013720..14bbf7c0edd7 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -671,7 +671,7 @@ nm_os_pt_memdev_iomap(struct ptnetmap_memdev *ptn_dev, vm_paddr_t *nm_paddr, &rid, 0, ~0, *mem_size, RF_ACTIVE); if (ptn_dev->pci_mem == NULL) { *nm_paddr = 0; - *nm_addr = 0; + *nm_addr = NULL; return ENOMEM; } diff --git a/sys/dev/netmap/netmap_mem2.c b/sys/dev/netmap/netmap_mem2.c index ce633134b934..d6bc2863027e 100644 --- a/sys/dev/netmap/netmap_mem2.c +++ b/sys/dev/netmap/netmap_mem2.c @@ -2146,7 +2146,7 @@ netmap_mem_pt_guest_deref(struct netmap_mem_d *nmd) if (ptnmd->ptn_dev) { nm_os_pt_memdev_iounmap(ptnmd->ptn_dev); } - ptnmd->nm_addr = 0; + ptnmd->nm_addr = NULL; ptnmd->nm_paddr = 0; } } From b0936e78766f7fae22a0d941e006f5f755507674 Mon Sep 17 00:00:00 2001 From: tuexen Date: Fri, 21 Jul 2017 07:44:43 +0000 Subject: [PATCH 34/49] Fix getsockopt() for listening sockets when using SO_SNDBUF, SO_RCVBUF, SO_SNDLOWAT, SO_RCVLOWAT. Since r31972 it only worked for non-listening sockets. Sponsored by: Netflix, Inc. --- sys/kern/uipc_socket.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index b11d2f78852f..bd08461b1516 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -3020,19 +3020,23 @@ integer: goto integer; case SO_SNDBUF: - optval = so->so_snd.sb_hiwat; + optval = SOLISTENING(so) ? so->sol_sbsnd_hiwat : + so->so_snd.sb_hiwat; goto integer; case SO_RCVBUF: - optval = so->so_rcv.sb_hiwat; + optval = SOLISTENING(so) ? so->sol_sbrcv_hiwat : + so->so_rcv.sb_hiwat; goto integer; case SO_SNDLOWAT: - optval = so->so_snd.sb_lowat; + optval = SOLISTENING(so) ? so->sol_sbsnd_lowat : + so->so_snd.sb_lowat; goto integer; case SO_RCVLOWAT: - optval = so->so_rcv.sb_lowat; + optval = SOLISTENING(so) ? so->sol_sbrcv_lowat : + so->so_rcv.sb_lowat; goto integer; case SO_SNDTIMEO: From 26c9d238517281b2cdfa00b29c4707fca0c43121 Mon Sep 17 00:00:00 2001 From: robak Date: Fri, 21 Jul 2017 08:50:22 +0000 Subject: [PATCH 35/49] Remove stack guard option from hardening menu. Since kib's change the stack guard is now ON by default, this option in hardening menu of bsdinstall is no longer needed. Submitted by: Bartlomiej Rutkowski Reviewed by: bapt Approved by: bapt MFC after: 1 day Sponsored by: Pixeware LTD Differential Revision: https://reviews.freebsd.org/D11686 --- usr.sbin/bsdinstall/scripts/hardening | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/hardening b/usr.sbin/bsdinstall/scripts/hardening index 471108013d21..1ea312db7ef7 100755 --- a/usr.sbin/bsdinstall/scripts/hardening +++ b/usr.sbin/bsdinstall/scripts/hardening @@ -42,11 +42,10 @@ FEATURES=$( dialog --backtitle "FreeBSD Installer" \ "3 read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-off} \ "4 proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-off} \ "5 random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \ - "6 stack_guard" "Set stack guard buffer size to 2MB" ${stack_guard:-off} \ - "7 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \ - "8 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \ - "9 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-off} \ - "10 secure_console" "Enable console password prompt" ${secure_console:-off} \ + "6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \ + "7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \ + "8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-off} \ + "9 secure_console" "Enable console password prompt" ${secure_console:-off} \ 2>&1 1>&3 ) exec 3>&- @@ -69,9 +68,6 @@ for feature in $FEATURES; do if [ "$feature" = "random_pid" ]; then echo kern.randompid=$(jot -r 1 9999) >> $BSDINSTALL_TMPETC/sysctl.conf.hardening fi - if [ "$feature" = "stack_guard" ]; then - echo security.bsd.stack_guard_page=512 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening - fi if [ "$feature" = "clear_tmp" ]; then echo 'clear_tmp_enable="YES"' >> $BSDINSTALL_TMPETC/rc.conf.hardening fi From 5fbfd0bc63e1a65a7350b04fef63bf9cc051e58b Mon Sep 17 00:00:00 2001 From: trasz Date: Fri, 21 Jul 2017 13:27:25 +0000 Subject: [PATCH 36/49] Use more usual formatting for the EXAMPLES section of ktrace(1). MFC after: 2 weeks Sponsored by: DARPA, AFRL --- usr.bin/ktrace/ktrace.1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/usr.bin/ktrace/ktrace.1 b/usr.bin/ktrace/ktrace.1 index 915bc183ee3a..8a713760a3a0 100644 --- a/usr.bin/ktrace/ktrace.1 +++ b/usr.bin/ktrace/ktrace.1 @@ -28,7 +28,7 @@ .\" @(#)ktrace.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd March 31, 2016 +.Dd July 24, 2017 .Dt KTRACE 1 .Os .Sh NAME @@ -148,31 +148,31 @@ and .Ar command options are mutually exclusive. .Sh EXAMPLES -# trace all kernel operations of process id 34 +Trace all kernel operations of process id 34: .Dl $ ktrace -p 34 .Pp -# trace all kernel operations of processes in process group 15 and -# pass the trace flags to all current and future children +Trace all kernel operations of processes in process group 15 and +pass the trace flags to all current and future children: .Dl $ ktrace -idg 15 .Pp -# disable all tracing of process 65 +Disable all tracing of process 65: .Dl $ ktrace -cp 65 .Pp -# disable tracing signals on process 70 and all current children +Disable tracing signals on process 70 and all current children: .Dl $ ktrace -t s -cdp 70 .Pp -# enable tracing of +Enable tracing of .Tn I/O -on process 67 +on process 67: .Dl $ ktrace -ti -p 67 .Pp -# run the command "w", tracing only system calls +Run the command "w", tracing only system calls: .Dl $ ktrace -tc w .Pp -# disable all tracing to the file "tracedata" +Disable all tracing to the file "tracedata": .Dl $ ktrace -c -f tracedata .Pp -# disable tracing of all user-owned processes +Disable tracing of all user-owned processes: .Dl $ ktrace -C .Sh SEE ALSO .Xr kdump 1 , From 551282a86b28ae6d2cb92470327bfa353cd8c389 Mon Sep 17 00:00:00 2001 From: trasz Date: Fri, 21 Jul 2017 13:50:59 +0000 Subject: [PATCH 37/49] Use more usual formatting for the EXAMPLES section of truss(1). MFC after: 2 weeks Sponsored by: DARPA, AFRL --- usr.bin/truss/truss.1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/truss/truss.1 b/usr.bin/truss/truss.1 index 0246fa933928..e7b363187419 100644 --- a/usr.bin/truss/truss.1 +++ b/usr.bin/truss/truss.1 @@ -92,11 +92,13 @@ and options are mutually exclusive.) .El .Sh EXAMPLES -# Follow the system calls used in echoing "hello" +Follow the system calls used in echoing "hello": .Dl $ truss /bin/echo hello -# Do the same, but put the output into a file +.Pp +Do the same, but put the output into a file: .Dl $ truss -o /tmp/truss.out /bin/echo hello -# Follow an already-running process +.Pp +Follow an already-running process: .Dl $ truss -p 34 .Sh SEE ALSO .Xr kdump 1 , From 08f3d69b700d7216524db0ec472818fb2b457b2c Mon Sep 17 00:00:00 2001 From: trasz Date: Fri, 21 Jul 2017 13:58:51 +0000 Subject: [PATCH 38/49] Make truss(1) cross-reference dtrace(1) and bump .Dd. MFC after: 2 weeks Sponsored by: DARPA, AFRL --- usr.bin/truss/truss.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/truss/truss.1 b/usr.bin/truss/truss.1 index e7b363187419..5c75bacc587c 100644 --- a/usr.bin/truss/truss.1 +++ b/usr.bin/truss/truss.1 @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.Dd February 23, 2016 +.Dd July 24, 2017 .Dt TRUSS 1 .Os .Sh NAME @@ -101,6 +101,7 @@ Do the same, but put the output into a file: Follow an already-running process: .Dl $ truss -p 34 .Sh SEE ALSO +.Xr dtrace 1 , .Xr kdump 1 , .Xr ktrace 1 , .Xr ptrace 2 , From 3eebf9cc696f031a114339041dad6de75fdf7a4c Mon Sep 17 00:00:00 2001 From: br Date: Fri, 21 Jul 2017 14:14:47 +0000 Subject: [PATCH 39/49] Fix style: change spaces to tabs. Sponsored by: DARPA, AFRL --- sys/vm/vm_object.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 83284aec8e88..60c98214af5d 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -171,11 +171,11 @@ struct vm_object { #define OBJ_FICTITIOUS 0x0001 /* (c) contains fictitious pages */ #define OBJ_UNMANAGED 0x0002 /* (c) contains unmanaged pages */ #define OBJ_POPULATE 0x0004 /* pager implements populate() */ -#define OBJ_DEAD 0x0008 /* dead objects (during rundown) */ +#define OBJ_DEAD 0x0008 /* dead objects (during rundown) */ #define OBJ_NOSPLIT 0x0010 /* dont split this object */ #define OBJ_UMTXDEAD 0x0020 /* umtx pshared was terminated */ -#define OBJ_PIPWNT 0x0040 /* paging in progress wanted */ -#define OBJ_MIGHTBEDIRTY 0x0100 /* object might be dirty, only for vnode */ +#define OBJ_PIPWNT 0x0040 /* paging in progress wanted */ +#define OBJ_MIGHTBEDIRTY 0x0100 /* object might be dirty, only for vnode */ #define OBJ_TMPFS_NODE 0x0200 /* object belongs to tmpfs VREG node */ #define OBJ_TMPFS_DIRTY 0x0400 /* dirty tmpfs obj */ #define OBJ_COLORED 0x1000 /* pg_color is defined */ From c8b8ae9609edaaa7f1704c9ee9c7ced6fe172749 Mon Sep 17 00:00:00 2001 From: br Date: Fri, 21 Jul 2017 14:50:32 +0000 Subject: [PATCH 40/49] Add warning flags for GCC 7.1.0 compiler. Sponsored by: DARPA, AFRL --- share/mk/bsd.sys.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 20ea85f3d9a3..2eaf973618ed 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -145,6 +145,23 @@ CWARNFLAGS+= -Wno-error=misleading-indentation \ -Wno-error=unused-const-variable .endif +# GCC 7.1.0 +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 70100 +CWARNFLAGS+= -Wno-error=deprecated \ + -Wno-error=pointer-compare \ + -Wno-error=format-truncation \ + -Wno-error=implicit-fallthrough \ + -Wno-error=expansion-to-defined \ + -Wno-error=int-in-bool-context \ + -Wno-error=bool-operation \ + -Wno-error=format-overflow \ + -Wno-error=stringop-overflow \ + -Wno-error=memset-elt-size \ + -Wno-error=int-in-bool-context \ + -Wno-error=unused-const-variable \ + -Wno-error=nonnull +.endif + # How to handle FreeBSD custom printf format specifiers. .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600 FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__ From 8d64b20efc241e5d7aab3a450a1b86083dc2cdef Mon Sep 17 00:00:00 2001 From: asomers Date: Fri, 21 Jul 2017 15:09:24 +0000 Subject: [PATCH 41/49] Implement SIGEV_THREAD notifications for lio_listio(2) Our man pages have always indicated that this was supported, but in fact the feature was never implemented for lio_listio(2). Reviewed by: jhb, kib (earlier version) MFC after: 20 days Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11680 --- lib/librt/Symbol.map | 1 + lib/librt/aio.c | 47 +++++++++++++++++++++++++++++++++------- tests/sys/aio/lio_test.c | 4 ++-- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/lib/librt/Symbol.map b/lib/librt/Symbol.map index a4a88b947070..c11b88397afd 100644 --- a/lib/librt/Symbol.map +++ b/lib/librt/Symbol.map @@ -26,6 +26,7 @@ FBSD_1.0 { }; FBSD_1.5 { + lio_listio; mq_getfd_np; timer_oshandle_np; }; diff --git a/lib/librt/aio.c b/lib/librt/aio.c index af88cf3affdd..fd26a9f68e53 100644 --- a/lib/librt/aio.c +++ b/lib/librt/aio.c @@ -44,6 +44,7 @@ __weak_reference(__aio_write, aio_write); __weak_reference(__aio_return, aio_return); __weak_reference(__aio_waitcomplete, aio_waitcomplete); __weak_reference(__aio_fsync, aio_fsync); +__weak_reference(__lio_listio, lio_listio); typedef void (*aio_func)(union sigval val, struct aiocb *iocb); @@ -53,6 +54,8 @@ extern ssize_t __sys_aio_waitcomplete(struct aiocb **iocbp, struct timespec *tim extern ssize_t __sys_aio_return(struct aiocb *iocb); extern int __sys_aio_error(struct aiocb *iocb); extern int __sys_aio_fsync(int op, struct aiocb *iocb); +extern int __sys_lio_listio(int mode, struct aiocb * const list[], int nent, + struct sigevent *sig); static void aio_dispatch(struct sigev_node *sn) @@ -63,8 +66,8 @@ aio_dispatch(struct sigev_node *sn) } static int -aio_sigev_alloc(struct aiocb *iocb, struct sigev_node **sn, - struct sigevent *saved_ev) +aio_sigev_alloc(sigev_id_t id, struct sigevent *sigevent, + struct sigev_node **sn, struct sigevent *saved_ev) { if (__sigev_check_init()) { /* This might be that thread library is not enabled. */ @@ -72,15 +75,15 @@ aio_sigev_alloc(struct aiocb *iocb, struct sigev_node **sn, return (-1); } - *sn = __sigev_alloc(SI_ASYNCIO, &iocb->aio_sigevent, NULL, 1); + *sn = __sigev_alloc(SI_ASYNCIO, sigevent, NULL, 1); if (*sn == NULL) { errno = EAGAIN; return (-1); } - *saved_ev = iocb->aio_sigevent; - (*sn)->sn_id = (sigev_id_t)iocb; - __sigev_get_sigevent(*sn, &iocb->aio_sigevent, (*sn)->sn_id); + *saved_ev = *sigevent; + (*sn)->sn_id = id; + __sigev_get_sigevent(*sn, sigevent, (*sn)->sn_id); (*sn)->sn_dispatch = aio_dispatch; __sigev_list_lock(); @@ -102,7 +105,8 @@ aio_io(struct aiocb *iocb, int (*sysfunc)(struct aiocb *iocb)) return (ret); } - ret = aio_sigev_alloc(iocb, &sn, &saved_ev); + ret = aio_sigev_alloc((sigev_id_t)iocb, &iocb->aio_sigevent, &sn, + &saved_ev); if (ret) return (ret); ret = sysfunc(iocb); @@ -183,7 +187,8 @@ __aio_fsync(int op, struct aiocb *iocb) if (iocb->aio_sigevent.sigev_notify != SIGEV_THREAD) return __sys_aio_fsync(op, iocb); - ret = aio_sigev_alloc(iocb, &sn, &saved_ev); + ret = aio_sigev_alloc((sigev_id_t)iocb, &iocb->aio_sigevent, &sn, + &saved_ev); if (ret) return (ret); ret = __sys_aio_fsync(op, iocb); @@ -197,3 +202,29 @@ __aio_fsync(int op, struct aiocb *iocb) } return (ret); } + +int +__lio_listio(int mode, struct aiocb * const list[], int nent, + struct sigevent *sig) +{ + struct sigev_node *sn; + struct sigevent saved_ev; + int ret, err; + + if (sig == NULL || sig->sigev_notify != SIGEV_THREAD) + return (__sys_lio_listio(mode, list, nent, sig)); + + ret = aio_sigev_alloc((sigev_id_t)list, sig, &sn, &saved_ev); + if (ret) + return (ret); + ret = __sys_lio_listio(mode, list, nent, sig); + *sig = saved_ev; + if (ret != 0) { + err = errno; + __sigev_list_lock(); + __sigev_delete_node(sn); + __sigev_list_unlock(); + errno = err; + } + return (ret); +} diff --git a/tests/sys/aio/lio_test.c b/tests/sys/aio/lio_test.c index 0e26aaa351fa..a87933cccbac 100644 --- a/tests/sys/aio/lio_test.c +++ b/tests/sys/aio/lio_test.c @@ -119,8 +119,8 @@ ATF_TC_BODY(lio_listio_empty_nowait_thread, tc) struct aiocb *list = NULL; struct sigevent sev; - atf_tc_expect_fail("Bug 220459 - lio_listio(2) doesn't support" - " SIGEV_THREAD"); + atf_tc_expect_timeout("Bug 220398 - lio_listio(2) never sends" + "asynchronous notification if nent==0"); ATF_REQUIRE_EQ(0, sem_init(&completions, false, 0)); bzero(&sev, sizeof(sev)); sev.sigev_notify = SIGEV_THREAD; From f4c07936e6a725fe461ee2b22300d8fb75b675c5 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Fri, 21 Jul 2017 16:14:06 +0000 Subject: [PATCH 42/49] Properly set userid for truncate_test. MFC after: 1 week Sponsored by: Dell EMC Isilon --- lib/libc/tests/sys/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index b363fe0df8bd..5b1a867bf29a 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -87,7 +87,7 @@ FILESGROUPS+= truncate_test_FILES truncate_test_FILES= truncate_test.root_owned truncate_test_FILESDIR= ${TESTSDIR} truncate_test_FILESMODE= 0600 -truncate_test_FILESOWNER= root +truncate_test_FILESOWN= root truncate_test_FILESGRP= wheel truncate_test_FILESPACKAGE= ${PACKAGE} From 3abbcde98f966bb9ed58a3ebb2acbb9450b6f3a3 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Fri, 21 Jul 2017 16:14:35 +0000 Subject: [PATCH 43/49] Respect INSTALL_AS_USER for FILES. MFC after: 2 weeks Sponsored by: Dell EMC Isilon --- share/mk/bsd.files.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk index 5dd51adc1d23..2eac6221406f 100644 --- a/share/mk/bsd.files.mk +++ b/share/mk/bsd.files.mk @@ -26,6 +26,10 @@ installfiles: installfiles-${group} ${group}OWN?= ${SHAREOWN} ${group}GRP?= ${SHAREGRP} +.if ${MK_INSTALL_AS_USER} == "yes" +${group}OWN= ${SHAREOWN} +${group}GRP= ${SHAREGRP} +.endif ${group}MODE?= ${SHAREMODE} ${group}DIR?= ${BINDIR} STAGE_SETS+= ${group:C,[/*],_,g} @@ -46,6 +50,10 @@ _${group}FILES= defined(${group}NAME_${file:T}) || defined(${group}NAME) ${group}OWN_${file:T}?= ${${group}OWN} ${group}GRP_${file:T}?= ${${group}GRP} +.if ${MK_INSTALL_AS_USER} == "yes" +${group}OWN_${file:T}= ${SHAREOWN} +${group}GRP_${file:T}= ${SHAREGRP} +.endif ${group}MODE_${file:T}?= ${${group}MODE} ${group}DIR_${file:T}?= ${${group}DIR} .if defined(${group}NAME) From dfe1112fa878c5d8fa0605d1de10c96ecc993569 Mon Sep 17 00:00:00 2001 From: rlibby Date: Fri, 21 Jul 2017 17:11:36 +0000 Subject: [PATCH 44/49] __pcpu: gcc -Wredundant-decls Pollution from counter.h made __pcpu visible in amd64/pmap.c. Delete the existing extern decl of __pcpu in amd64/pmap.c and avoid referring to that symbol, instead accessing the pcpu region via PCPU_SET macros. Also delete an unused extern decl of __pcpu from mp_x86.c. Reviewed by: kib Approved by: markj (mentor) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11666 --- sys/amd64/amd64/pmap.c | 6 ++---- sys/x86/x86/mp_x86.c | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 05572ebd0ab2..5b0bdfdd1c1e 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -274,8 +274,6 @@ pmap_modified_bit(pmap_t pmap) return (mask); } -extern struct pcpu __pcpu[]; - #if !defined(DIAGNOSTIC) #ifdef __GNUC_GNU_INLINE__ #define PMAP_INLINE __attribute__((__gnu_inline__)) inline @@ -1063,8 +1061,8 @@ pmap_bootstrap(vm_paddr_t *firstaddr) kernel_pmap->pm_pcids[i].pm_pcid = PMAP_PCID_KERN; kernel_pmap->pm_pcids[i].pm_gen = 1; } - __pcpu[0].pc_pcid_next = PMAP_PCID_KERN + 1; - __pcpu[0].pc_pcid_gen = 1; + PCPU_SET(pcid_next, PMAP_PCID_KERN + 1); + PCPU_SET(pcid_gen, 1); /* * pcpu area for APs is zeroed during AP startup. * pc_pcid_next and pc_pcid_gen are initialized by AP diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 63146dc0173b..e69a7d704f09 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -90,8 +90,6 @@ int mcount_lock; int mp_naps; /* # of Applications processors */ int boot_cpu_id = -1; /* designated BSP */ -extern struct pcpu __pcpu[]; - /* AP uses this during bootstrap. Do not staticize. */ char *bootSTK; int bootAP; From f9b3dd8ec2bc26d7c65d57887551e8532becaadd Mon Sep 17 00:00:00 2001 From: sbruno Date: Fri, 21 Jul 2017 17:42:54 +0000 Subject: [PATCH 45/49] Do not update stats counter in SWI context. Defer to the already existing admin thread. Submitted by: Matt Macy Sponsored by: Limelight Networks --- sys/dev/e1000/if_em.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 5202c4367a6f..ed6da9d9517b 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -1663,9 +1663,7 @@ em_if_timer(if_ctx_t ctx, uint16_t qid) if (qid != 0) return; - em_if_update_admin_status(ctx); - em_update_stats_counters(adapter); - + iflib_admin_intr_deferred(ctx); /* Reset LAA into RAR[0] on 82571 */ if ((adapter->hw.mac.type == e1000_82571) && e1000_get_laa_state_82571(&adapter->hw)) @@ -1781,6 +1779,7 @@ em_if_update_admin_status(if_ctx_t ctx) iflib_link_state_change(ctx, LINK_STATE_DOWN, ifp->if_baudrate); printf("link state changed to down\n"); } + em_update_stats_counters(adapter); E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_LINK | E1000_IMS_LSC); } From bb2f26cb70ea35dcd9d47ed3e452d5362dcd16f1 Mon Sep 17 00:00:00 2001 From: dim Date: Fri, 21 Jul 2017 17:59:54 +0000 Subject: [PATCH 46/49] Pull in r295886 from upstream clang trunk (by Richard Smith): PR32034: Evaluate _Atomic(T) in-place when T is a class or array type. This is necessary in order for the evaluation of an _Atomic initializer for those types to have an associated object, which an initializer for class or array type needs. This fixes an assertion when building recent versions of LinuxCNC. Reported by: trasz PR: 220883 MFC after: 1 week --- .../llvm/tools/clang/lib/AST/ExprConstant.cpp | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp index 2c0fce91844c..1bf098144e5a 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp @@ -1404,7 +1404,8 @@ static bool EvaluateIntegerOrLValue(const Expr *E, APValue &Result, EvalInfo &Info); static bool EvaluateFloat(const Expr *E, APFloat &Result, EvalInfo &Info); static bool EvaluateComplex(const Expr *E, ComplexValue &Res, EvalInfo &Info); -static bool EvaluateAtomic(const Expr *E, APValue &Result, EvalInfo &Info); +static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result, + EvalInfo &Info); static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result); //===----------------------------------------------------------------------===// @@ -4691,7 +4692,10 @@ public: case CK_AtomicToNonAtomic: { APValue AtomicVal; - if (!EvaluateAtomic(E->getSubExpr(), AtomicVal, Info)) + // This does not need to be done in place even for class/array types: + // atomic-to-non-atomic conversion implies copying the object + // representation. + if (!Evaluate(AtomicVal, Info, E->getSubExpr())) return false; return DerivedSuccess(AtomicVal, E); } @@ -9565,10 +9569,11 @@ bool ComplexExprEvaluator::VisitInitListExpr(const InitListExpr *E) { namespace { class AtomicExprEvaluator : public ExprEvaluatorBase { + const LValue *This; APValue &Result; public: - AtomicExprEvaluator(EvalInfo &Info, APValue &Result) - : ExprEvaluatorBaseTy(Info), Result(Result) {} + AtomicExprEvaluator(EvalInfo &Info, const LValue *This, APValue &Result) + : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {} bool Success(const APValue &V, const Expr *E) { Result = V; @@ -9578,7 +9583,10 @@ public: bool ZeroInitialization(const Expr *E) { ImplicitValueInitExpr VIE( E->getType()->castAs()->getValueType()); - return Evaluate(Result, Info, &VIE); + // For atomic-qualified class (and array) types in C++, initialize the + // _Atomic-wrapped subobject directly, in-place. + return This ? EvaluateInPlace(Result, Info, *This, &VIE) + : Evaluate(Result, Info, &VIE); } bool VisitCastExpr(const CastExpr *E) { @@ -9586,15 +9594,17 @@ public: default: return ExprEvaluatorBaseTy::VisitCastExpr(E); case CK_NonAtomicToAtomic: - return Evaluate(Result, Info, E->getSubExpr()); + return This ? EvaluateInPlace(Result, Info, *This, E->getSubExpr()) + : Evaluate(Result, Info, E->getSubExpr()); } } }; } // end anonymous namespace -static bool EvaluateAtomic(const Expr *E, APValue &Result, EvalInfo &Info) { +static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result, + EvalInfo &Info) { assert(E->isRValue() && E->getType()->isAtomicType()); - return AtomicExprEvaluator(Info, Result).Visit(E); + return AtomicExprEvaluator(Info, This, Result).Visit(E); } //===----------------------------------------------------------------------===// @@ -9699,8 +9709,17 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) { if (!EvaluateVoid(E, Info)) return false; } else if (T->isAtomicType()) { - if (!EvaluateAtomic(E, Result, Info)) - return false; + QualType Unqual = T.getAtomicUnqualifiedType(); + if (Unqual->isArrayType() || Unqual->isRecordType()) { + LValue LV; + LV.set(E, Info.CurrentCall->Index); + APValue &Value = Info.CurrentCall->createTemporary(E, false); + if (!EvaluateAtomic(E, &LV, Value, Info)) + return false; + } else { + if (!EvaluateAtomic(E, nullptr, Result, Info)) + return false; + } } else if (Info.getLangOpts().CPlusPlus11) { Info.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType(); return false; @@ -9725,10 +9744,16 @@ static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This, if (E->isRValue()) { // Evaluate arrays and record types in-place, so that later initializers can // refer to earlier-initialized members of the object. - if (E->getType()->isArrayType()) + QualType T = E->getType(); + if (T->isArrayType()) return EvaluateArray(E, This, Result, Info); - else if (E->getType()->isRecordType()) + else if (T->isRecordType()) return EvaluateRecord(E, This, Result, Info); + else if (T->isAtomicType()) { + QualType Unqual = T.getAtomicUnqualifiedType(); + if (Unqual->isArrayType() || Unqual->isRecordType()) + return EvaluateAtomic(E, &This, Result, Info); + } } // For any other type, in-place evaluation is unimportant. From 9a191031a0fb879785732d449f8e3088687b8f7c Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 21 Jul 2017 18:28:27 +0000 Subject: [PATCH 47/49] Account for lock recursion when transfering snaplock to the vnode lock in ffs_snapremove(). Apparently ffs_snapremove() may be called with the snap lock recursed, at least one trace demonstrated this when snapshot vnode was unlinked while synced. It was inactivated from the syncer thread. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/ufs/ffs/ffs_snapshot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index e9908a8b994b..2792c6027a2e 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -1598,7 +1598,7 @@ ffs_snapremove(vp) struct buf *ibp; struct fs *fs; ufs2_daddr_t numblks, blkno, dblk; - int error, loc, last; + int error, i, last, loc; struct snapdata *sn; ip = VTOI(vp); @@ -1618,10 +1618,14 @@ ffs_snapremove(vp) ip->i_nextsnap.tqe_prev = 0; VI_UNLOCK(devvp); lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL); + for (i = 0; i < sn->sn_lock.lk_recurse; i++) + lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL); KASSERT(vp->v_vnlock == &sn->sn_lock, ("ffs_snapremove: lost lock mutation")); vp->v_vnlock = &vp->v_lock; VI_LOCK(devvp); + while (sn->sn_lock.lk_recurse > 0) + lockmgr(&sn->sn_lock, LK_RELEASE, NULL); lockmgr(&sn->sn_lock, LK_RELEASE, NULL); try_free_snapdata(devvp); } else From 404727946649a30d5dafa0b20c9ec994dbd77f6c Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 21 Jul 2017 18:36:17 +0000 Subject: [PATCH 48/49] Unlock correct lock in ffs_snapblkfree(). It is possible for ffs_snapblkfree() to race and lock snaplock while the devvp snapdata is instantiated, but no snapshots exist. In this case the loop over snapshots in ffs_snapblkfree() is not executed, and the local variable vp is left initialized to NULL. Unlock using &sn->sn_lock and not vp->v_vnlock. For the inodes on the snapshot list, the locks are same. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/ufs/ffs/ffs_snapshot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 2792c6027a2e..66a677330ce2 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -1935,7 +1935,7 @@ retry: */ if (error != 0 && wkhd != NULL) softdep_freework(wkhd); - lockmgr(vp->v_vnlock, LK_RELEASE, NULL); + lockmgr(&sn->sn_lock, LK_RELEASE, NULL); return (error); } From 24abfe4267ad39d5bfd2ba81d38e1de35f40a3a0 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 21 Jul 2017 18:42:35 +0000 Subject: [PATCH 49/49] Improve publication of the newly allocated snapdata. For freshly allocated snapdata, Lock sn_lock in advance, so si_snapdata readers see the locked snapdata and not race. For existing snapdata, if the thread was put to sleep waiting for sn_lock, re-read si_snapdata. This either closes the race or makes the reliance on LK_DRAIN less important. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks --- sys/ufs/ffs/ffs_snapshot.c | 50 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index 66a677330ce2..b4e31258f60d 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -2638,8 +2638,8 @@ try_free_snapdata(struct vnode *devvp) static struct snapdata * ffs_snapdata_acquire(struct vnode *devvp) { - struct snapdata *nsn; - struct snapdata *sn; + struct snapdata *nsn, *sn; + int error; /* * Allocate a free snapdata. This is done before acquiring the @@ -2647,23 +2647,37 @@ ffs_snapdata_acquire(struct vnode *devvp) * held. */ nsn = ffs_snapdata_alloc(); - /* - * If there snapshots already exist on this filesystem grab a - * reference to the shared lock. Otherwise this is the first - * snapshot on this filesystem and we need to use our - * pre-allocated snapdata. - */ - VI_LOCK(devvp); - if (devvp->v_rdev->si_snapdata == NULL) { - devvp->v_rdev->si_snapdata = nsn; - nsn = NULL; + + for (;;) { + VI_LOCK(devvp); + sn = devvp->v_rdev->si_snapdata; + if (sn == NULL) { + /* + * This is the first snapshot on this + * filesystem and we use our pre-allocated + * snapdata. Publish sn with the sn_lock + * owned by us, to avoid the race. + */ + error = lockmgr(&nsn->sn_lock, LK_EXCLUSIVE | + LK_NOWAIT, NULL); + if (error != 0) + panic("leaked sn, lockmgr error %d", error); + sn = devvp->v_rdev->si_snapdata = nsn; + VI_UNLOCK(devvp); + nsn = NULL; + break; + } + + /* + * There is a snapshots which already exists on this + * filesystem, grab a reference to the common lock. + */ + error = lockmgr(&sn->sn_lock, LK_INTERLOCK | + LK_EXCLUSIVE | LK_SLEEPFAIL, VI_MTX(devvp)); + if (error == 0) + break; } - sn = devvp->v_rdev->si_snapdata; - /* - * Acquire the snapshot lock. - */ - lockmgr(&sn->sn_lock, - LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY, VI_MTX(devvp)); + /* * Free any unused snapdata. */