From owner-svn-src-stable@FreeBSD.ORG Sun Aug 30 22:36:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69259106568F; Sun, 30 Aug 2009 22:36:47 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C0E98FC1C; Sun, 30 Aug 2009 22:36:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7UMal8T008294; Sun, 30 Aug 2009 22:36:47 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7UMalEU008292; Sun, 30 Aug 2009 22:36:47 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200908302236.n7UMalEU008292@svn.freebsd.org> From: Qing Li Date: Sun, 30 Aug 2009 22:36:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196671 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Aug 2009 22:36:47 -0000 Author: qingli Date: Sun Aug 30 22:36:46 2009 New Revision: 196671 URL: http://svn.freebsd.org/changeset/base/196671 Log: MFC r196569 When multiple interfaces exist in the system, with each interface having an IPv6 address assigned to it, and if an incoming packet received on one interface has a packet destination address that belongs to another interface, the routing table is consulted to determine how to reach this packet destination. Since the packet destination is an interface address, the route table will return a host route with the loopback interface as rt_ifp. The input code must recognize this fact, instead of using the loopback interface, the input code performs a search to find the right interface that owns the given IPv6 address. Reviewed by: bz, gnn, kmacy Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/ip6_input.c Modified: stable/8/sys/netinet6/ip6_input.c ============================================================================== --- stable/8/sys/netinet6/ip6_input.c Sun Aug 30 22:35:20 2009 (r196670) +++ stable/8/sys/netinet6/ip6_input.c Sun Aug 30 22:36:46 2009 (r196671) @@ -628,8 +628,27 @@ passin: &rt6_key(rin6.ro_rt)->sin6_addr) #endif rin6.ro_rt->rt_ifp->if_type == IFT_LOOP) { - struct in6_ifaddr *ia6 = - (struct in6_ifaddr *)rin6.ro_rt->rt_ifa; + int free_ia6 = 0; + struct in6_ifaddr *ia6; + + /* + * found the loopback route to the interface address + */ + if (rin6.ro_rt->rt_gateway->sa_family == AF_LINK) { + struct sockaddr_in6 dest6; + + bzero(&dest6, sizeof(dest6)); + dest6.sin6_family = AF_INET6; + dest6.sin6_len = sizeof(dest6); + dest6.sin6_addr = ip6->ip6_dst; + ia6 = (struct in6_ifaddr *) + ifa_ifwithaddr((struct sockaddr *)&dest6); + if (ia6 == NULL) + goto bad; + free_ia6 = 1; + } + else + ia6 = (struct in6_ifaddr *)rin6.ro_rt->rt_ifa; /* * record address information into m_tag. @@ -647,6 +666,8 @@ passin: /* Count the packet in the ip address stats */ ia6->ia_ifa.if_ipackets++; ia6->ia_ifa.if_ibytes += m->m_pkthdr.len; + if (ia6 != NULL && free_ia6 != 0) + ifa_free(&ia6->ia_ifa); goto hbhcheck; } else { char ip6bufs[INET6_ADDRSTRLEN]; @@ -657,6 +678,8 @@ passin: ip6_sprintf(ip6bufs, &ip6->ip6_src), ip6_sprintf(ip6bufd, &ip6->ip6_dst))); + if (ia6 != NULL && free_ia6 != 0) + ifa_free(&ia6->ia_ifa); goto bad; } } From owner-svn-src-stable@FreeBSD.ORG Sun Aug 30 22:39:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92A5C106566B; Sun, 30 Aug 2009 22:39:49 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FAEE8FC32; Sun, 30 Aug 2009 22:39:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7UMdnqP008414; Sun, 30 Aug 2009 22:39:49 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7UMdnWb008412; Sun, 30 Aug 2009 22:39:49 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200908302239.n7UMdnWb008412@svn.freebsd.org> From: Qing Li Date: Sun, 30 Aug 2009 22:39:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196672 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Aug 2009 22:39:49 -0000 Author: qingli Date: Sun Aug 30 22:39:49 2009 New Revision: 196672 URL: http://svn.freebsd.org/changeset/base/196672 Log: MFC r196608 Do not try to free the rt_lle entry of the cached route in ip_output() if the cached route was not initialized from the flow-table. The rt_lle entry is invalid unless it has been initialized through the flow-table. Reviewed by: kmacy, rwatson Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/ip_output.c Modified: stable/8/sys/netinet/ip_output.c ============================================================================== --- stable/8/sys/netinet/ip_output.c Sun Aug 30 22:36:46 2009 (r196671) +++ stable/8/sys/netinet/ip_output.c Sun Aug 30 22:39:49 2009 (r196672) @@ -202,10 +202,8 @@ again: if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || dst->sin_family != AF_INET || dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { - if (!nortfree) { + if (!nortfree) RTFREE(ro->ro_rt); - LLE_FREE(ro->ro_lle); - } ro->ro_rt = (struct rtentry *)NULL; ro->ro_lle = (struct llentry *)NULL; } From owner-svn-src-stable@FreeBSD.ORG Sun Aug 30 22:42:33 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75ED91065676; Sun, 30 Aug 2009 22:42:33 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6262C8FC17; Sun, 30 Aug 2009 22:42:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7UMgXQl008520; Sun, 30 Aug 2009 22:42:33 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7UMgWW2008517; Sun, 30 Aug 2009 22:42:32 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200908302242.n7UMgWW2008517@svn.freebsd.org> From: Qing Li Date: Sun, 30 Aug 2009 22:42:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196673 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Aug 2009 22:42:33 -0000 Author: qingli Date: Sun Aug 30 22:42:32 2009 New Revision: 196673 URL: http://svn.freebsd.org/changeset/base/196673 Log: MFC r196609 In ip_output(), the flow-table module must not try to cache L2/L3 information for interface of IFF_POINTOPOINT or IFF_LOOPBACK type. Since the L2 information (rt_lle) is invalid for these interface types, accidental caching attempt will trigger panic when the invalid rt_lle reference is accessed. When installing a new route, or when updating an existing route, the user supplied gateway address may be an interface address (this is particularly true for point-to-point interface related modules such as ppp, if_tun, if_gif). Currently the routing command handler always set the RTF_GATEWAY flag if the gateway address is given as part of the command paramters. Therefore the gateway address must be verified against interface addresses or else the route would be treated as an indirect route, thus making that route unusable. Reviewed by: kmacy, julian, rwatson Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/flowtable.c stable/8/sys/net/rtsock.c Modified: stable/8/sys/net/flowtable.c ============================================================================== --- stable/8/sys/net/flowtable.c Sun Aug 30 22:39:49 2009 (r196672) +++ stable/8/sys/net/flowtable.c Sun Aug 30 22:42:32 2009 (r196673) @@ -692,6 +692,12 @@ uncached: struct rtentry *rt = ro->ro_rt; struct ifnet *ifp = rt->rt_ifp; + if (ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) { + RTFREE(rt); + ro->ro_rt = NULL; + return (ENOENT); + } + if (rt->rt_flags & RTF_GATEWAY) l3addr = rt->rt_gateway; else Modified: stable/8/sys/net/rtsock.c ============================================================================== --- stable/8/sys/net/rtsock.c Sun Aug 30 22:39:49 2009 (r196672) +++ stable/8/sys/net/rtsock.c Sun Aug 30 22:42:32 2009 (r196673) @@ -513,6 +513,39 @@ route_output(struct mbuf *m, struct sock senderr(error); } + /* + * The given gateway address may be an interface address. + * For example, issuing a "route change" command on a route + * entry that was created from a tunnel, and the gateway + * address given is the local end point. In this case the + * RTF_GATEWAY flag must be cleared or the destination will + * not be reachable even though there is no error message. + */ + if (info.rti_info[RTAX_GATEWAY] != NULL && + info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) { + struct route gw_ro; + + bzero(&gw_ro, sizeof(gw_ro)); + gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; + rtalloc_ign(&gw_ro, 0); + /* + * A host route through the loopback interface is + * installed for each interface adddress. In pre 8.0 + * releases the interface address of a PPP link type + * is not reachable locally. This behavior is fixed as + * part of the new L2/L3 redesign and rewrite work. The + * signature of this interface address route is the + * AF_LINK sa_family type of the rt_gateway, and the + * rt_ifp has the IFF_LOOPBACK flag set. + */ + if (gw_ro.ro_rt != NULL && + gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK && + gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) + info.rti_flags &= ~RTF_GATEWAY; + if (gw_ro.ro_rt != NULL) + RTFREE(gw_ro.ro_rt); + } + switch (rtm->rtm_type) { struct rtentry *saved_nrt; @@ -714,7 +747,7 @@ route_output(struct mbuf *m, struct sock RT_UNLOCK(rt); senderr(error); } - rt->rt_flags |= RTF_GATEWAY; + rt->rt_flags |= (RTF_GATEWAY & info.rti_flags); } if (info.rti_ifa != NULL && info.rti_ifa != rt->rt_ifa) { From owner-svn-src-stable@FreeBSD.ORG Sun Aug 30 22:44:13 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30B3C106568B; Sun, 30 Aug 2009 22:44:13 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D97A8FC1B; Sun, 30 Aug 2009 22:44:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7UMiDPg008613; Sun, 30 Aug 2009 22:44:13 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7UMiCRF008611; Sun, 30 Aug 2009 22:44:13 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200908302244.n7UMiCRF008611@svn.freebsd.org> From: Qing Li Date: Sun, 30 Aug 2009 22:44:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196674 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Aug 2009 22:44:13 -0000 Author: qingli Date: Sun Aug 30 22:44:12 2009 New Revision: 196674 URL: http://svn.freebsd.org/changeset/base/196674 Log: MFC r196649 Prefix on-link verification is being performed on statically configured prefixes. Since these statically configured prefixes do not have any associated advertising routers, these prefixes are treated as unreachable and those prefix routes are deleted from the routing table. Therefore bypass prefixes that are not learned from router advertisements during prefix on-link check. Reviewed by: hrs Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/nd6_rtr.c Modified: stable/8/sys/netinet6/nd6_rtr.c ============================================================================== --- stable/8/sys/netinet6/nd6_rtr.c Sun Aug 30 22:42:32 2009 (r196673) +++ stable/8/sys/netinet6/nd6_rtr.c Sun Aug 30 22:44:12 2009 (r196674) @@ -1415,6 +1415,9 @@ pfxlist_onlink_check() if (pr->ndpr_raf_onlink == 0) continue; + if (pr->ndpr_raf_auto == 0) + continue; + if ((pr->ndpr_stateflags & NDPRF_DETACHED) == 0 && find_pfxlist_reachable_router(pr) == NULL) pr->ndpr_stateflags |= NDPRF_DETACHED; @@ -1431,6 +1434,9 @@ pfxlist_onlink_check() if (pr->ndpr_raf_onlink == 0) continue; + if (pr->ndpr_raf_auto == 0) + continue; + if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0) pr->ndpr_stateflags &= ~NDPRF_DETACHED; } @@ -1454,6 +1460,9 @@ pfxlist_onlink_check() if (pr->ndpr_raf_onlink == 0) continue; + if (pr->ndpr_raf_auto == 0) + continue; + if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 && (pr->ndpr_stateflags & NDPRF_ONLINK) != 0) { if ((e = nd6_prefix_offlink(pr)) != 0) { From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 00:18:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 368AE106566B; Mon, 31 Aug 2009 00:18:18 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23A8C8FC13; Mon, 31 Aug 2009 00:18:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V0IIlH010645; Mon, 31 Aug 2009 00:18:18 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V0IIC1010643; Mon, 31 Aug 2009 00:18:18 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200908310018.n7V0IIC1010643@svn.freebsd.org> From: Qing Li Date: Mon, 31 Aug 2009 00:18:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196679 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 00:18:18 -0000 Author: qingli Date: Mon Aug 31 00:18:17 2009 New Revision: 196679 URL: http://svn.freebsd.org/changeset/base/196679 Log: As part of r196609, a call to "rtalloc" did not take the fib into account. So call the appropriate "rtalloc_ign_fib()" instead of calling "rtalloc_ign()". Reviewed by: pointed out by bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/rtsock.c Modified: stable/8/sys/net/rtsock.c ============================================================================== --- stable/8/sys/net/rtsock.c Mon Aug 31 00:14:37 2009 (r196678) +++ stable/8/sys/net/rtsock.c Mon Aug 31 00:18:17 2009 (r196679) @@ -527,7 +527,7 @@ route_output(struct mbuf *m, struct sock bzero(&gw_ro, sizeof(gw_ro)); gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; - rtalloc_ign(&gw_ro, 0); + rtalloc_ign_fib(&gw_ro, 0, so->so_fibnum); /* * A host route through the loopback interface is * installed for each interface adddress. In pre 8.0 From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 00:52:10 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD2EE106568B; Mon, 31 Aug 2009 00:52:10 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB4AF8FC17; Mon, 31 Aug 2009 00:52:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V0qApB011359; Mon, 31 Aug 2009 00:52:10 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V0qA6P011357; Mon, 31 Aug 2009 00:52:10 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <200908310052.n7V0qA6P011357@svn.freebsd.org> From: Max Laier Date: Mon, 31 Aug 2009 00:52:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196680 - in stable/7/sys: . contrib/pf contrib/pf/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 00:52:11 -0000 Author: mlaier Date: Mon Aug 31 00:52:10 2009 New Revision: 196680 URL: http://svn.freebsd.org/changeset/base/196680 Log: MFC r196551: Fix argument ordering to memcpy as well as the size of the copy in the (theoretical) case that pfi_buffer_cnt should be greater than ~_max. Submitted by: pjd Reviewed by: {krw,sthen,markus}@openbsd.org Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/contrib/pf/net/pf_if.c Modified: stable/7/sys/contrib/pf/net/pf_if.c ============================================================================== --- stable/7/sys/contrib/pf/net/pf_if.c Mon Aug 31 00:18:17 2009 (r196679) +++ stable/7/sys/contrib/pf/net/pf_if.c Mon Aug 31 00:52:10 2009 (r196680) @@ -660,7 +660,7 @@ pfi_address_add(struct sockaddr *sa, int "(%d/%d)\n", pfi_buffer_cnt, PFI_BUFFER_MAX); return; } - memcpy(pfi_buffer, p, pfi_buffer_cnt * sizeof(*pfi_buffer)); + memcpy(p, pfi_buffer, pfi_buffer_max * sizeof(*pfi_buffer)); /* no need to zero buffer */ free(pfi_buffer, PFI_MTYPE); pfi_buffer = p; From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 00:54:14 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E46A7106566C; Mon, 31 Aug 2009 00:54:14 +0000 (UTC) (envelope-from mlaier@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D29478FC13; Mon, 31 Aug 2009 00:54:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V0sEkg011437; Mon, 31 Aug 2009 00:54:14 GMT (envelope-from mlaier@svn.freebsd.org) Received: (from mlaier@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V0sEKO011434; Mon, 31 Aug 2009 00:54:14 GMT (envelope-from mlaier@svn.freebsd.org) Message-Id: <200908310054.n7V0sEKO011434@svn.freebsd.org> From: Max Laier Date: Mon, 31 Aug 2009 00:54:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196681 - in stable/7/sys: . contrib/pf contrib/pf/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 00:54:15 -0000 Author: mlaier Date: Mon Aug 31 00:54:14 2009 New Revision: 196681 URL: http://svn.freebsd.org/changeset/base/196681 Log: MFC r196372: If we cannot immediately get the pf_consistency_lock in the purge thread, restart the scan after acquiring the lock the hard way. Otherwise we might end up with a dead reference. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/contrib/pf/net/pf.c stable/7/sys/contrib/pf/net/pfvar.h Modified: stable/7/sys/contrib/pf/net/pf.c ============================================================================== --- stable/7/sys/contrib/pf/net/pf.c Mon Aug 31 00:52:10 2009 (r196680) +++ stable/7/sys/contrib/pf/net/pf.c Mon Aug 31 00:54:14 2009 (r196681) @@ -972,6 +972,9 @@ void pf_purge_thread(void *v) { int nloops = 0, s; +#ifdef __FreeBSD__ + int locked; +#endif for (;;) { tsleep(pf_purge_thread, PWAIT, "pftm", 1 * hz); @@ -979,14 +982,19 @@ pf_purge_thread(void *v) #ifdef __FreeBSD__ sx_slock(&pf_consistency_lock); PF_LOCK(); + locked = 0; if (pf_end_threads) { - pf_purge_expired_states(pf_status.states); + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + pf_purge_expired_states(pf_status.states, 1); pf_purge_expired_fragments(); - pf_purge_expired_src_nodes(0); + pf_purge_expired_src_nodes(1); pf_end_threads++; - sx_sunlock(&pf_consistency_lock); + sx_xunlock(&pf_consistency_lock); PF_UNLOCK(); wakeup(pf_purge_thread); kthread_exit(0); @@ -995,20 +1003,44 @@ pf_purge_thread(void *v) s = splsoftnet(); /* process a fraction of the state table every second */ +#ifdef __FreeBSD__ + if(!pf_purge_expired_states(1 + (pf_status.states + / pf_default_rule.timeout[PFTM_INTERVAL]), 0)) { + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + locked = 1; + + pf_purge_expired_states(1 + (pf_status.states + / pf_default_rule.timeout[PFTM_INTERVAL]), 1); + } +#else pf_purge_expired_states(1 + (pf_status.states / pf_default_rule.timeout[PFTM_INTERVAL])); +#endif /* purge other expired types every PFTM_INTERVAL seconds */ if (++nloops >= pf_default_rule.timeout[PFTM_INTERVAL]) { pf_purge_expired_fragments(); - pf_purge_expired_src_nodes(0); + if (!pf_purge_expired_src_nodes(locked)) { + PF_UNLOCK(); + sx_sunlock(&pf_consistency_lock); + sx_xlock(&pf_consistency_lock); + PF_LOCK(); + locked = 1; + pf_purge_expired_src_nodes(1); + } nloops = 0; } splx(s); #ifdef __FreeBSD__ PF_UNLOCK(); - sx_sunlock(&pf_consistency_lock); + if (locked) + sx_xunlock(&pf_consistency_lock); + else + sx_sunlock(&pf_consistency_lock); #endif } } @@ -1057,8 +1089,13 @@ pf_state_expires(const struct pf_state * return (state->expire + timeout); } +#ifdef __FreeBSD__ +int +pf_purge_expired_src_nodes(int waslocked) +#else void pf_purge_expired_src_nodes(int waslocked) +#endif { struct pf_src_node *cur, *next; int locked = waslocked; @@ -1069,12 +1106,8 @@ pf_purge_expired_src_nodes(int waslocked if (cur->states <= 0 && cur->expire <= time_second) { if (! locked) { #ifdef __FreeBSD__ - if (!sx_try_upgrade(&pf_consistency_lock)) { - PF_UNLOCK(); - sx_sunlock(&pf_consistency_lock); - sx_xlock(&pf_consistency_lock); - PF_LOCK(); - } + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); #else rw_enter_write(&pf_consistency_lock); #endif @@ -1101,6 +1134,10 @@ pf_purge_expired_src_nodes(int waslocked #else rw_exit_write(&pf_consistency_lock); #endif + +#ifdef __FreeBSD__ + return (1); +#endif } void @@ -1203,12 +1240,21 @@ pf_free_state(struct pf_state *cur) pf_status.states--; } +#ifdef __FreeBSD__ +int +pf_purge_expired_states(u_int32_t maxcheck, int waslocked) +#else void pf_purge_expired_states(u_int32_t maxcheck) +#endif { static struct pf_state *cur = NULL; struct pf_state *next; +#ifdef __FreeBSD__ + int locked = waslocked; +#else int locked = 0; +#endif while (maxcheck--) { /* wrap to start of list when we hit the end */ @@ -1225,12 +1271,8 @@ pf_purge_expired_states(u_int32_t maxche /* free unlinked state */ if (! locked) { #ifdef __FreeBSD__ - if (!sx_try_upgrade(&pf_consistency_lock)) { - PF_UNLOCK(); - sx_sunlock(&pf_consistency_lock); - sx_xlock(&pf_consistency_lock); - PF_LOCK(); - } + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); #else rw_enter_write(&pf_consistency_lock); #endif @@ -1242,12 +1284,8 @@ pf_purge_expired_states(u_int32_t maxche pf_unlink_state(cur); if (! locked) { #ifdef __FreeBSD__ - if (!sx_try_upgrade(&pf_consistency_lock)) { - PF_UNLOCK(); - sx_sunlock(&pf_consistency_lock); - sx_xlock(&pf_consistency_lock); - PF_LOCK(); - } + if (!sx_try_upgrade(&pf_consistency_lock)) + return (0); #else rw_enter_write(&pf_consistency_lock); #endif @@ -1258,10 +1296,13 @@ pf_purge_expired_states(u_int32_t maxche cur = next; } - if (locked) #ifdef __FreeBSD__ + if (!waslocked && locked) sx_downgrade(&pf_consistency_lock); + + return (1); #else + if (locked) rw_exit_write(&pf_consistency_lock); #endif } Modified: stable/7/sys/contrib/pf/net/pfvar.h ============================================================================== --- stable/7/sys/contrib/pf/net/pfvar.h Mon Aug 31 00:52:10 2009 (r196680) +++ stable/7/sys/contrib/pf/net/pfvar.h Mon Aug 31 00:54:14 2009 (r196681) @@ -1593,8 +1593,13 @@ extern struct pool pf_state_pl, pf_alt extern struct pool pf_state_scrub_pl; #endif extern void pf_purge_thread(void *); +#ifdef __FreeBSD__ +extern int pf_purge_expired_src_nodes(int); +extern int pf_purge_expired_states(u_int32_t, int); +#else extern void pf_purge_expired_src_nodes(int); extern void pf_purge_expired_states(u_int32_t); +#endif extern void pf_unlink_state(struct pf_state *); extern void pf_free_state(struct pf_state *); extern int pf_insert_state(struct pfi_kif *, From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 02:22:20 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 247D0106568F; Mon, 31 Aug 2009 02:22:20 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 110458FC0A; Mon, 31 Aug 2009 02:22:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V2MI5r013283; Mon, 31 Aug 2009 02:22:18 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V2MISr013278; Mon, 31 Aug 2009 02:22:18 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200908310222.n7V2MISr013278@svn.freebsd.org> From: Edwin Groothuis Date: Mon, 31 Aug 2009 02:22:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196683 - in stable/7: lib/libc lib/libc/stdtime usr.sbin/zic X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 02:22:20 -0000 Author: edwin Date: Mon Aug 31 02:22:18 2009 New Revision: 196683 URL: http://svn.freebsd.org/changeset/base/196683 Log: MFC of r192625, r192890, r194783, r196587: r192625: MFC of tzcode2009e: Upgrade of the tzcode from 2004a to 2009e. Changes are numerous, but include... - New format of the output of zic, which supports both 32 and 64 bit time_t formats. - zdump on 64 bit platforms will actually produce some output instead of doing nothing for a looooooooong time. - linux_base-fX, with X >= at least 8, will work without problems related to the local time again. The original patch, based on the 2008e, has been running for a long time on both my laptop and desktop machine and have been tested by other people. After the installation of this code and the running of zic(8), you need to run tzsetup(8) again to install the new datafile. r192890: MFC of tzcode2009h - Clarify the license for the tzcode: public domain r194783: Remove duplicate if-statement on gmt_is_set in gmtsub(). r196587: MFC of tzcode2009k zic.c: Do not end a binary file with a POSIX-style time zone string for locations that end up in permanent DST (thanks to Andreas Schwab). Deleted: stable/7/usr.sbin/zic/Arts.htm stable/7/usr.sbin/zic/tz-art.htm stable/7/usr.sbin/zic/tz-link.htm Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdtime/asctime.c stable/7/lib/libc/stdtime/difftime.c stable/7/lib/libc/stdtime/localtime.c stable/7/lib/libc/stdtime/private.h stable/7/lib/libc/stdtime/strftime.c stable/7/lib/libc/stdtime/time2posix.3 stable/7/lib/libc/stdtime/tzfile.5 stable/7/lib/libc/stdtime/tzfile.h stable/7/usr.sbin/zic/ (props changed) stable/7/usr.sbin/zic/README stable/7/usr.sbin/zic/Theory stable/7/usr.sbin/zic/ialloc.c stable/7/usr.sbin/zic/private.h stable/7/usr.sbin/zic/scheck.c stable/7/usr.sbin/zic/zdump.8 stable/7/usr.sbin/zic/zdump.c stable/7/usr.sbin/zic/zic.8 stable/7/usr.sbin/zic/zic.c Modified: stable/7/lib/libc/stdtime/asctime.c ============================================================================== --- stable/7/lib/libc/stdtime/asctime.c Mon Aug 31 00:56:06 2009 (r196682) +++ stable/7/lib/libc/stdtime/asctime.c Mon Aug 31 02:22:18 2009 (r196683) @@ -1,12 +1,18 @@ /* ** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). +** 1996-06-05 by Arthur David Olson. +*/ + +/* +** Avoid the temptation to punt entirely to strftime; +** the output of strftime is supposed to be locale specific +** whereas the output of asctime is supposed to be constant. */ #include #ifndef lint #ifndef NOID -static char elsieid[] __unused = "@(#)asctime.c 7.9"; +static char elsieid[] __unused = "@(#)asctime.c 8.2"; #endif /* !defined NOID */ #endif /* !defined lint */ __FBSDID("$FreeBSD$"); @@ -19,7 +25,57 @@ __FBSDID("$FreeBSD$"); #include "tzfile.h" /* -** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12. +** Some systems only handle "%.2d"; others only handle "%02d"; +** "%02.2d" makes (most) everybody happy. +** At least some versions of gcc warn about the %02.2d; +** we conditionalize below to avoid the warning. +*/ +/* +** All years associated with 32-bit time_t values are exactly four digits long; +** some years associated with 64-bit time_t values are not. +** Vintage programs are coded for years that are always four digits long +** and may assume that the newline always lands in the same place. +** For years that are less than four digits, we pad the output with +** leading zeroes to get the newline in the traditional place. +** The -4 ensures that we get four characters of output even if +** we call a strftime variant that produces fewer characters for some years. +** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year, +** but many implementations pad anyway; most likely the standards are buggy. +*/ +#ifdef __GNUC__ +#define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" +#else /* !defined __GNUC__ */ +#define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n" +#endif /* !defined __GNUC__ */ +/* +** For years that are more than four digits we put extra spaces before the year +** so that code trying to overwrite the newline won't end up overwriting +** a digit within a year and truncating the year (operating on the assumption +** that no output is better than wrong output). +*/ +#ifdef __GNUC__ +#define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n" +#else /* !defined __GNUC__ */ +#define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n" +#endif /* !defined __GNUC__ */ + +#define STD_ASCTIME_BUF_SIZE 26 +/* +** Big enough for something such as +** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n +** (two three-character abbreviations, five strings denoting integers, +** seven explicit spaces, two explicit colons, a newline, +** and a trailing ASCII nul). +** The values above are for systems where an int is 32 bits and are provided +** as an example; the define below calculates the maximum for the system at +** hand. +*/ +#define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1) + +static char buf_asctime[MAX_ASCTIME_BUF_SIZE]; + +/* +** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition. */ char * @@ -36,6 +92,8 @@ char * buf; }; const char * wn; const char * mn; + char year[INT_STRLEN_MAXIMUM(int) + 2]; + char result[MAX_ASCTIME_BUF_SIZE]; if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) wn = "???"; @@ -44,35 +102,41 @@ char * buf; mn = "???"; else mn = mon_name[timeptr->tm_mon]; /* - ** The X3J11-suggested format is - ** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n" - ** Since the .2 in 02.2d is ignored, we drop it. + ** Use strftime's %Y to generate the year, to avoid overflow problems + ** when computing timeptr->tm_year + TM_YEAR_BASE. + ** Assume that strftime is unaffected by other out-of-range members + ** (e.g., timeptr->tm_mday) when processing "%Y". */ - (void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n", + (void) strftime(year, sizeof year, "%Y", timeptr); + /* + ** We avoid using snprintf since it's not available on all systems. + */ + (void) sprintf(result, + ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B), wn, mn, timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, - TM_YEAR_BASE + timeptr->tm_year); - return buf; + year); + if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) { + (void) strcpy(buf, result); + return buf; + } else { +#ifdef EOVERFLOW + errno = EOVERFLOW; +#else /* !defined EOVERFLOW */ + errno = EINVAL; +#endif /* !defined EOVERFLOW */ + return NULL; + } } /* -** A la X3J11, with core dump avoidance. +** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition. */ char * asctime(timeptr) const struct tm * timeptr; { - /* - ** Big enough for something such as - ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n - ** (two three-character abbreviations, five strings denoting integers, - ** three explicit spaces, two explicit colons, a newline, - ** and a trailing ASCII nul). - */ - static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + - 3 + 2 + 1 + 1]; - - return asctime_r(timeptr, result); + return asctime_r(timeptr, buf_asctime); } Modified: stable/7/lib/libc/stdtime/difftime.c ============================================================================== --- stable/7/lib/libc/stdtime/difftime.c Mon Aug 31 00:56:06 2009 (r196682) +++ stable/7/lib/libc/stdtime/difftime.c Mon Aug 31 02:22:18 2009 (r196683) @@ -1,12 +1,12 @@ /* ** This file is in the public domain, so clarified as of -** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +** 1996-06-05 by Arthur David Olson. */ #include #ifndef lint #ifndef NOID -static char elsieid[] __unused = "@(#)difftime.c 7.9"; +static char elsieid[] __unused = "@(#)difftime.c 8.1"; #endif /* !defined NOID */ #endif /* !defined lint */ __FBSDID("$FreeBSD$"); @@ -14,74 +14,56 @@ __FBSDID("$FreeBSD$"); /*LINTLIBRARY*/ #include "namespace.h" -#include "private.h" +#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */ #include "un-namespace.h" -/* -** Algorithm courtesy Paul Eggert (eggert@twinsun.com). -*/ - -#ifdef HAVE_LONG_DOUBLE -#define long_double long double -#endif /* defined HAVE_LONG_DOUBLE */ -#ifndef HAVE_LONG_DOUBLE -#define long_double double -#endif /* !defined HAVE_LONG_DOUBLE */ - double difftime(time1, time0) const time_t time1; const time_t time0; { - time_t delta; - time_t hibit; - - { - time_t tt; - double d; - long_double ld; - - if (sizeof tt < sizeof d) - return (double) time1 - (double) time0; - if (sizeof tt < sizeof ld) - return (long_double) time1 - (long_double) time0; + /* + ** If (sizeof (double) > sizeof (time_t)) simply convert and subtract + ** (assuming that the larger type has more precision). + ** This is the common real-world case circa 2004. + */ + if (sizeof (double) > sizeof (time_t)) + return (double) time1 - (double) time0; + if (!TYPE_INTEGRAL(time_t)) { + /* + ** time_t is floating. + */ + return time1 - time0; + } + if (!TYPE_SIGNED(time_t)) { + /* + ** time_t is integral and unsigned. + ** The difference of two unsigned values can't overflow + ** if the minuend is greater than or equal to the subtrahend. + */ + if (time1 >= time0) + return time1 - time0; + else return -((double) (time0 - time1)); } - if (time1 < time0) - return -difftime(time0, time1); /* - ** As much as possible, avoid loss of precision - ** by computing the difference before converting to double. + ** time_t is integral and signed. + ** Handle cases where both time1 and time0 have the same sign + ** (meaning that their difference cannot overflow). */ - delta = time1 - time0; - if (delta >= 0) - return delta; + if ((time1 < 0) == (time0 < 0)) + return time1 - time0; /* - ** Repair delta overflow. + ** time1 and time0 have opposite signs. + ** Punt if unsigned long is too narrow. */ - hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1); + if (sizeof (unsigned long) < sizeof (time_t)) + return (double) time1 - (double) time0; /* - ** The following expression rounds twice, which means - ** the result may not be the closest to the true answer. - ** For example, suppose time_t is 64-bit signed int, - ** long_double is IEEE 754 double with default rounding, - ** time1 = 9223372036854775807 and time0 = -1536. - ** Then the true difference is 9223372036854777343, - ** which rounds to 9223372036854777856 - ** with a total error of 513. - ** But delta overflows to -9223372036854774273, - ** which rounds to -9223372036854774784, and correcting - ** this by subtracting 2 * (long_double) hibit - ** (i.e. by adding 2**64 = 18446744073709551616) - ** yields 9223372036854776832, which - ** rounds to 9223372036854775808 - ** with a total error of 1535 instead. - ** This problem occurs only with very large differences. - ** It's too painful to fix this portably. - ** We are not alone in this problem; - ** some C compilers round twice when converting - ** large unsigned types to small floating types, - ** so if time_t is unsigned the "return delta" above - ** has the same double-rounding problem with those compilers. + ** Stay calm...decent optimizers will eliminate the complexity below. */ - return delta - 2 * (long_double) hibit; + if (time1 >= 0 /* && time0 < 0 */) + return (unsigned long) time1 + + (unsigned long) (-(time0 + 1)) + 1; + return -(double) ((unsigned long) time0 + + (unsigned long) (-(time1 + 1)) + 1); } Modified: stable/7/lib/libc/stdtime/localtime.c ============================================================================== --- stable/7/lib/libc/stdtime/localtime.c Mon Aug 31 00:56:06 2009 (r196682) +++ stable/7/lib/libc/stdtime/localtime.c Mon Aug 31 02:22:18 2009 (r196683) @@ -1,20 +1,19 @@ /* ** This file is in the public domain, so clarified as of -** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). +** 1996-06-05 by Arthur David Olson. */ #include #ifndef lint #ifndef NOID -static char elsieid[] __unused = "@(#)localtime.c 7.78"; +static char elsieid[] __unused = "@(#)localtime.c 8.9"; #endif /* !defined NOID */ #endif /* !defined lint */ __FBSDID("$FreeBSD$"); /* -** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). -** POSIX-style TZ environment variable handling from Guy Harris -** (guy@auspex.com). +** Leap second handling from Bradley White. +** POSIX-style TZ environment variable handling from Guy Harris. */ /*LINTLIBRARY*/ @@ -28,6 +27,20 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "tzfile.h" +#include "float.h" /* for FLT_MAX and DBL_MAX */ + +#ifndef TZ_ABBR_MAX_LEN +#define TZ_ABBR_MAX_LEN 16 +#endif /* !defined TZ_ABBR_MAX_LEN */ + +#ifndef TZ_ABBR_CHAR_SET +#define TZ_ABBR_CHAR_SET \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._" +#endif /* !defined TZ_ABBR_CHAR_SET */ + +#ifndef TZ_ABBR_ERR_CHAR +#define TZ_ABBR_ERR_CHAR '_' +#endif /* !defined TZ_ABBR_ERR_CHAR */ #include "libc_private.h" @@ -74,16 +87,16 @@ __FBSDID("$FreeBSD$"); ** 5. They might reference tm.TM_ZONE after calling offtime. ** What's best to do in the above cases is open to debate; ** for now, we just set things up so that in any of the five cases -** WILDABBR is used. Another possibility: initialize tzname[0] to the +** WILDABBR is used. Another possibility: initialize tzname[0] to the ** string "tzname[0] used before set", and similarly for the other cases. -** And another: initialize tzname[0] to "ERA", with an explanation in the +** And another: initialize tzname[0] to "ERA", with an explanation in the ** manual page of what this "time zone abbreviation" means (doing this so ** that tzname[0] has the "normal" length of three characters). */ #define WILDABBR " " #endif /* !defined WILDABBR */ -static char wildabbr[] = "WILDABBR"; +static char wildabbr[] = WILDABBR; /* * In June 2004 it was decided UTC was a more appropriate default time @@ -130,6 +143,8 @@ struct state { int timecnt; int typecnt; int charcnt; + int goback; + int goahead; time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; struct ttinfo ttis[TZ_MAX_TYPES]; @@ -155,40 +170,49 @@ struct rule { */ static long detzcode(const char * codep); +static time_t detzcode64(const char * codep); +static int differ_by_repeat(time_t t1, time_t t0); static const char * getzname(const char * strp); +static const char * getqzname(const char * strp, const int delim); static const char * getnum(const char * strp, int * nump, int min, int max); static const char * getsecs(const char * strp, long * secsp); static const char * getoffset(const char * strp, long * offsetp); static const char * getrule(const char * strp, struct rule * rulep); static void gmtload(struct state * sp); -static void gmtsub(const time_t * timep, long offset, +static struct tm * gmtsub(const time_t * timep, long offset, struct tm * tmp); -static void localsub(const time_t * timep, long offset, +static struct tm * localsub(const time_t * timep, long offset, struct tm * tmp); static int increment_overflow(int * number, int delta); +static int leaps_thru_end_of(int y); +static int long_increment_overflow(long * number, int delta); +static int long_normalize_overflow(long * tensptr, + int * unitsptr, int base); static int normalize_overflow(int * tensptr, int * unitsptr, int base); static void settzname(void); static time_t time1(struct tm * tmp, - void(*funcp) (const time_t *, + struct tm * (*funcp)(const time_t *, long, struct tm *), long offset); static time_t time2(struct tm *tmp, - void(*funcp) (const time_t *, + struct tm * (*funcp)(const time_t *, long, struct tm*), long offset, int * okayp); static time_t time2sub(struct tm *tmp, - void(*funcp) (const time_t *, + struct tm * (*funcp)(const time_t *, long, struct tm*), long offset, int * okayp, int do_norm_secs); -static void timesub(const time_t * timep, long offset, +static struct tm * timesub(const time_t * timep, long offset, const struct state * sp, struct tm * tmp); static int tmcomp(const struct tm * atmp, const struct tm * btmp); static time_t transtime(time_t janfirst, int year, const struct rule * rulep, long offset); -static int tzload(const char * name, struct state * sp); +static int typesequiv(const struct state * sp, int a, int b); +static int tzload(const char * name, struct state * sp, + int doextend); static int tzparse(const char * name, struct state * sp, int lastditch); @@ -224,7 +248,7 @@ char * tzname[2] = { ** Except for the strftime function, these functions [asctime, ** ctime, gmtime, localtime] return values in one of two static ** objects: a broken-down time structure and an array of char. -** Thanks to Paul Eggert (eggert@twinsun.com) for noting this. +** Thanks to Paul Eggert for noting this. */ static struct tm tm; @@ -245,12 +269,25 @@ const char * const codep; long result; int i; - result = (codep[0] & 0x80) ? ~0L : 0L; + result = (codep[0] & 0x80) ? ~0L : 0; for (i = 0; i < 4; ++i) result = (result << 8) | (codep[i] & 0xff); return result; } +static time_t +detzcode64(codep) +const char * const codep; +{ + register time_t result; + register int i; + + result = (codep[0] & 0x80) ? (~(int_fast64_t) 0) : 0; + for (i = 0; i < 8; ++i) + result = result * 256 + (codep[i] & 0xff); + return result; +} + static void settzname(void) { @@ -299,16 +336,58 @@ settzname(void) tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind]; } + /* + ** Finally, scrub the abbreviations. + ** First, replace bogus characters. + */ + for (i = 0; i < sp->charcnt; ++i) + if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL) + sp->chars[i] = TZ_ABBR_ERR_CHAR; + /* + ** Second, truncate long abbreviations. + */ + for (i = 0; i < sp->typecnt; ++i) { + register const struct ttinfo * const ttisp = &sp->ttis[i]; + register char * cp = &sp->chars[ttisp->tt_abbrind]; + + if (strlen(cp) > TZ_ABBR_MAX_LEN && + strcmp(cp, GRANDPARENTED) != 0) + *(cp + TZ_ABBR_MAX_LEN) = '\0'; + } +} + +static int +differ_by_repeat(t1, t0) +const time_t t1; +const time_t t0; +{ + int_fast64_t _t0 = t0; + int_fast64_t _t1 = t1; + + if (TYPE_INTEGRAL(time_t) && + TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS) + return 0; + //turn ((int_fast64_t)(t1 - t0) == SECSPERREPEAT); + return _t1 - _t0 == SECSPERREPEAT; } static int -tzload(name, sp) +tzload(name, sp, doextend) const char * name; struct state * const sp; +register const int doextend; { const char * p; int i; int fid; + int stored; + int nread; + union { + struct tzhead tzhead; + char buf[2 * sizeof(struct tzhead) + + 2 * sizeof *sp + + 4 * TZ_MAX_TIMES]; + } u; /* XXX The following is from OpenBSD, and I'm not sure it is correct */ if (name != NULL && issetugid() != 0) @@ -356,18 +435,13 @@ struct state * const sp; return -1; } } - { - struct tzhead * tzhp; - union { - struct tzhead tzhead; - char buf[sizeof *sp + sizeof *tzhp]; - } u; + nread = _read(fid, u.buf, sizeof u.buf); + if (_close(fid) < 0 || nread <= 0) + return -1; + for (stored = 4; stored <= 8; stored *= 2) { int ttisstdcnt; int ttisgmtcnt; - i = _read(fid, u.buf, sizeof u.buf); - if (_close(fid) != 0) - return -1; ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt); ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt); sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt); @@ -382,17 +456,19 @@ struct state * const sp; (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) return -1; - if (i - (p - u.buf) < sp->timecnt * 4 + /* ats */ + if (nread - (p - u.buf) < + sp->timecnt * stored + /* ats */ sp->timecnt + /* types */ - sp->typecnt * (4 + 2) + /* ttinfos */ + sp->typecnt * 6 + /* ttinfos */ sp->charcnt + /* chars */ - sp->leapcnt * (4 + 4) + /* lsinfos */ + sp->leapcnt * (stored + 4) + /* lsinfos */ ttisstdcnt + /* ttisstds */ ttisgmtcnt) /* ttisgmts */ return -1; for (i = 0; i < sp->timecnt; ++i) { - sp->ats[i] = detzcode(p); - p += 4; + sp->ats[i] = (stored == 4) ? + detzcode(p) : detzcode64(p); + p += stored; } for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; @@ -420,8 +496,9 @@ struct state * const sp; struct lsinfo * lsisp; lsisp = &sp->lsis[i]; - lsisp->ls_trans = detzcode(p); - p += 4; + lsisp->ls_trans = (stored == 4) ? + detzcode(p) : detzcode64(p); + p += stored; lsisp->ls_corr = detzcode(p); p += 4; } @@ -451,10 +528,127 @@ struct state * const sp; return -1; } } + /* + ** Out-of-sort ats should mean we're running on a + ** signed time_t system but using a data file with + ** unsigned values (or vice versa). + */ + for (i = 0; i < sp->timecnt - 2; ++i) + if (sp->ats[i] > sp->ats[i + 1]) { + ++i; + if (TYPE_SIGNED(time_t)) { + /* + ** Ignore the end (easy). + */ + sp->timecnt = i; + } else { + /* + ** Ignore the beginning (harder). + */ + register int j; + + for (j = 0; j + i < sp->timecnt; ++j) { + sp->ats[j] = sp->ats[j + i]; + sp->types[j] = sp->types[j + i]; + } + sp->timecnt = j; + } + break; + } + /* + ** If this is an old file, we're done. + */ + if (u.tzhead.tzh_version[0] == '\0') + break; + nread -= p - u.buf; + for (i = 0; i < nread; ++i) + u.buf[i] = p[i]; + /* + ** If this is a narrow integer time_t system, we're done. + */ + if (stored >= (int) sizeof(time_t) && TYPE_INTEGRAL(time_t)) + break; + } + if (doextend && nread > 2 && + u.buf[0] == '\n' && u.buf[nread - 1] == '\n' && + sp->typecnt + 2 <= TZ_MAX_TYPES) { + struct state ts; + register int result; + + u.buf[nread - 1] = '\0'; + result = tzparse(&u.buf[1], &ts, FALSE); + if (result == 0 && ts.typecnt == 2 && + sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) { + for (i = 0; i < 2; ++i) + ts.ttis[i].tt_abbrind += + sp->charcnt; + for (i = 0; i < ts.charcnt; ++i) + sp->chars[sp->charcnt++] = + ts.chars[i]; + i = 0; + while (i < ts.timecnt && + ts.ats[i] <= + sp->ats[sp->timecnt - 1]) + ++i; + while (i < ts.timecnt && + sp->timecnt < TZ_MAX_TIMES) { + sp->ats[sp->timecnt] = + ts.ats[i]; + sp->types[sp->timecnt] = + sp->typecnt + + ts.types[i]; + ++sp->timecnt; + ++i; + } + sp->ttis[sp->typecnt++] = ts.ttis[0]; + sp->ttis[sp->typecnt++] = ts.ttis[1]; + } + } + sp->goback = sp->goahead = FALSE; + if (sp->timecnt > 1) { + for (i = 1; i < sp->timecnt; ++i) + if (typesequiv(sp, sp->types[i], sp->types[0]) && + differ_by_repeat(sp->ats[i], sp->ats[0])) { + sp->goback = TRUE; + break; + } + for (i = sp->timecnt - 2; i >= 0; --i) + if (typesequiv(sp, sp->types[sp->timecnt - 1], + sp->types[i]) && + differ_by_repeat(sp->ats[sp->timecnt - 1], + sp->ats[i])) { + sp->goahead = TRUE; + break; + } } return 0; } +static int +typesequiv(sp, a, b) +const struct state * const sp; +const int a; +const int b; +{ + register int result; + + if (sp == NULL || + a < 0 || a >= sp->typecnt || + b < 0 || b >= sp->typecnt) + result = FALSE; + else { + register const struct ttinfo * ap = &sp->ttis[a]; + register const struct ttinfo * bp = &sp->ttis[b]; + result = ap->tt_gmtoff == bp->tt_gmtoff && + ap->tt_isdst == bp->tt_isdst && + ap->tt_ttisstd == bp->tt_ttisstd && + ap->tt_ttisgmt == bp->tt_ttisgmt && + strcmp(&sp->chars[ap->tt_abbrind], + &sp->chars[bp->tt_abbrind]) == 0; + } + return result; +} + static const int mon_lengths[2][MONSPERYEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } @@ -466,7 +660,7 @@ static const int year_lengths[2] = { /* ** Given a pointer into a time zone string, scan until a character that is not -** a valid character in a zone name is found. Return a pointer to that +** a valid character in a zone name is found. Return a pointer to that ** character. */ @@ -483,6 +677,25 @@ const char * strp; } /* +** Given a pointer into an extended time zone string, scan until the ending +** delimiter of the zone name is located. Return a pointer to the delimiter. +** +** As with getzname above, the legal character set is actually quite +** restricted, with other characters producing undefined results. +** We don't do any checking here; checking is done later in common-case code. +*/ + +static const char * +getqzname(register const char *strp, const int delim) +{ + register int c; + + while ((c = *strp) != '\0' && c != delim) + ++strp; + return strp; +} + +/* ** Given a pointer into a time zone string, extract a number from that string. ** Check that the number is within a specified range; if it is not, return ** NULL. @@ -547,7 +760,7 @@ long * const secsp; *secsp += num * SECSPERMIN; if (*strp == ':') { ++strp; - /* `SECSPERMIN' allows for leap seconds. */ + /* `SECSPERMIN' allows for leap seconds. */ strp = getnum(strp, &num, 0, SECSPERMIN); if (strp == NULL) return NULL; @@ -586,7 +799,7 @@ long * const offsetp; /* ** Given a pointer into a time zone string, extract a rule in the form -** date[/time]. See POSIX section 8 for the format of "date" and "time". +** date[/time]. See POSIX section 8 for the format of "date" and "time". ** If a valid rule is not found, return NULL. ** Otherwise, return a pointer to the first character not part of the rule. */ @@ -705,7 +918,7 @@ const long offset; dow += DAYSPERWEEK; /* - ** "dow" is the day-of-week of the first day of the month. Get + ** "dow" is the day-of-week of the first day of the month. Get ** the day-of-month (zero-origin) of the first "dow" day of the ** month. */ @@ -728,7 +941,7 @@ const long offset; /* ** "value" is the Epoch-relative time of 00:00:00 UTC on the day in - ** question. To get the Epoch-relative time of the specified local + ** question. To get the Epoch-relative time of the specified local ** time on that day, add the transition time and the current offset ** from UTC. */ @@ -766,10 +979,18 @@ const int lastditch; stdlen = (sizeof sp->chars) - 1; stdoffset = 0; } else { - name = getzname(name); - stdlen = name - stdname; - if (stdlen < 3) - return -1; + if (*name == '<') { + name++; + stdname = name; + name = getqzname(name, '>'); + if (*name != '>') + return (-1); + stdlen = name - stdname; + name++; + } else { + name = getzname(name); + stdlen = name - stdname; + } if (*name == '\0') return -1; /* was "stdoffset = 0;" */ else { @@ -778,15 +999,22 @@ const int lastditch; return -1; } } - load_result = tzload(TZDEFRULES, sp); + load_result = tzload(TZDEFRULES, sp, FALSE); if (load_result != 0) sp->leapcnt = 0; /* so, we're off a little */ if (*name != '\0') { - dstname = name; - name = getzname(name); - dstlen = name - dstname; /* length of DST zone name */ - if (dstlen < 3) - return -1; + if (*name == '<') { + dstname = ++name; + name = getqzname(name, '>'); + if (*name != '>') + return -1; + dstlen = name - dstname; + name++; + } else { + dstname = name; + name = getzname(name); + dstlen = name - dstname; /* length of DST zone name */ + } if (*name != '\0' && *name != ',' && *name != ';') { name = getoffset(name, &dstoffset); if (name == NULL) @@ -813,11 +1041,8 @@ const int lastditch; return -1; sp->typecnt = 2; /* standard time and DST */ /* - ** Two transitions per year, from EPOCH_YEAR to 2037. + ** Two transitions per year, from EPOCH_YEAR forward. */ - sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); - if (sp->timecnt > TZ_MAX_TIMES) - return -1; sp->ttis[0].tt_gmtoff = -dstoffset; sp->ttis[0].tt_isdst = 1; sp->ttis[0].tt_abbrind = stdlen + 1; @@ -827,7 +1052,12 @@ const int lastditch; atp = sp->ats; typep = sp->types; janfirst = 0; - for (year = EPOCH_YEAR; year <= 2037; ++year) { + sp->timecnt = 0; + for (year = EPOCH_YEAR; + sp->timecnt + 2 <= TZ_MAX_TIMES; + ++year) { + time_t newfirst; + starttime = transtime(janfirst, year, &start, stdoffset); endtime = transtime(janfirst, year, &end, @@ -843,8 +1073,13 @@ const int lastditch; *atp++ = endtime; *typep++ = 1; /* DST ends */ } - janfirst += year_lengths[isleap(year)] * + sp->timecnt += 2; + newfirst = janfirst; + newfirst += year_lengths[isleap(year)] * SECSPERDAY; + if (newfirst <= janfirst) + break; + janfirst = newfirst; } } else { long theirstdoffset; @@ -959,7 +1194,7 @@ static void gmtload(sp) struct state * const sp; { - if (tzload(gmt, sp) != 0) + if (tzload(gmt, sp, TRUE) != 0) (void) tzparse(gmt, sp, TRUE); } @@ -990,7 +1225,7 @@ tzsetwall_basic(int rdlocked) } } #endif /* defined ALL_STATE */ - if (tzload((char *) NULL, lclptr) != 0) + if (tzload((char *) NULL, lclptr, TRUE) != 0) gmtload(lclptr); settzname(); _RWLOCK_UNLOCK(&lcl_rwlock); @@ -1053,7 +1288,7 @@ tzset_basic(int rdlocked) lclptr->ttis[0].tt_gmtoff = 0; lclptr->ttis[0].tt_abbrind = 0; (void) strcpy(lclptr->chars, gmt); - } else if (tzload(name, lclptr) != 0) + } else if (tzload(name, lclptr, TRUE) != 0) if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) (void) gmtload(lclptr); settzname(); @@ -1072,14 +1307,14 @@ tzset(void) /* ** The easy way to behave "as if no library function calls" localtime ** is to not call it--so we drop its guts into "localsub", which can be -** freely called. (And no, the PANS doesn't require the above behavior-- +** freely called. (And no, the PANS doesn't require the above behavior-- ** but it *is* desirable.) ** ** The unused offset argument is for the benefit of mktime variants. */ /*ARGSUSED*/ -static void +static struct tm * localsub(timep, offset, tmp) const time_t * const timep; const long offset; @@ -1088,15 +1323,53 @@ struct tm * const tmp; struct state * sp; const struct ttinfo * ttisp; int i; - const time_t t = *timep; + struct tm * result; + const time_t t = *timep; sp = lclptr; #ifdef ALL_STATE - if (sp == NULL) { - gmtsub(timep, offset, tmp); - return; - } + if (sp == NULL) + return gmtsub(timep, offset, tmp); #endif /* defined ALL_STATE */ + if ((sp->goback && t < sp->ats[0]) || + (sp->goahead && t > sp->ats[sp->timecnt - 1])) { + time_t newt = t; + register time_t seconds; + register time_t tcycles; + register int_fast64_t icycles; + + if (t < sp->ats[0]) + seconds = sp->ats[0] - t; + else seconds = t - sp->ats[sp->timecnt - 1]; + --seconds; + tcycles = seconds / YEARSPERREPEAT / AVGSECSPERYEAR; + ++tcycles; + icycles = tcycles; + if (tcycles - icycles >= 1 || icycles - tcycles >= 1) + return NULL; + seconds = icycles; + seconds *= YEARSPERREPEAT; + seconds *= AVGSECSPERYEAR; + if (t < sp->ats[0]) + newt += seconds; + else newt -= seconds; + if (newt < sp->ats[0] || + newt > sp->ats[sp->timecnt - 1]) + return NULL; /* "cannot happen" */ + result = localsub(&newt, offset, tmp); + if (result == tmp) { + register time_t newy; + + newy = tmp->tm_year; + if (t < sp->ats[0]) + newy -= icycles * YEARSPERREPEAT; + else newy += icycles * YEARSPERREPEAT; + tmp->tm_year = newy; + if (tmp->tm_year != newy) + return NULL; + } + return result; + } if (sp->timecnt == 0 || t < sp->ats[0]) { i = 0; while (sp->ttis[i].tt_isdst) @@ -1105,10 +1378,17 @@ struct tm * const tmp; break; } } else { - for (i = 1; i < sp->timecnt; ++i) - if (t < sp->ats[i]) - break; - i = sp->types[i - 1]; + register int lo = 1; + register int hi = sp->timecnt; + + while (lo < hi) { + register int mid = (lo + hi) >> 1; + + if (t < sp->ats[mid]) + hi = mid; + else lo = mid + 1; + } + i = (int) sp->types[lo - 1]; } ttisp = &sp->ttis[i]; /* @@ -1117,12 +1397,13 @@ struct tm * const tmp; ** t += ttisp->tt_gmtoff; ** timesub(&t, 0L, sp, tmp); */ - timesub(&t, ttisp->tt_gmtoff, sp, tmp); + result = timesub(&t, ttisp->tt_gmtoff, sp, tmp); tmp->tm_isdst = ttisp->tt_isdst; tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind]; #ifdef TM_ZONE tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; #endif /* defined TM_ZONE */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 02:45:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D321A106566C; Mon, 31 Aug 2009 02:45:47 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C22048FC1D; Mon, 31 Aug 2009 02:45:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V2jl0O013839; Mon, 31 Aug 2009 02:45:47 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V2jliD013837; Mon, 31 Aug 2009 02:45:47 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200908310245.n7V2jliD013837@svn.freebsd.org> From: Edwin Groothuis Date: Mon, 31 Aug 2009 02:45:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196684 - stable/7 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 02:45:47 -0000 Author: edwin Date: Mon Aug 31 02:45:47 2009 New Revision: 196684 URL: http://svn.freebsd.org/changeset/base/196684 Log: MFC of r192625: Throw alert about the newly generated format of zic(8) and the necessarity to run tzsetup(8). Modified: stable/7/UPDATING (contents, props changed) Modified: stable/7/UPDATING ============================================================================== --- stable/7/UPDATING Mon Aug 31 02:22:18 2009 (r196683) +++ stable/7/UPDATING Mon Aug 31 02:45:47 2009 (r196684) @@ -8,6 +8,11 @@ Items affecting the ports and packages s /usr/ports/UPDATING. Please read that file before running portupgrade. +20090831: + The newly imported zic(8) produces a new format in the + output. Please run tzsetup(8) to install the newly created + data to /etc/localtime. + 20090731: The ABI of various structures related to the SYSV IPC API have been changed. Bump __FreeBSD_version to 702105. From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 09:08:15 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72B741065672; Mon, 31 Aug 2009 09:08:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F9E18FC17; Mon, 31 Aug 2009 09:08:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V98FbX021766; Mon, 31 Aug 2009 09:08:15 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V98FFd021764; Mon, 31 Aug 2009 09:08:15 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200908310908.n7V98FFd021764@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 31 Aug 2009 09:08:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196687 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 09:08:15 -0000 Author: kib Date: Mon Aug 31 09:08:14 2009 New Revision: 196687 URL: http://svn.freebsd.org/changeset/base/196687 Log: MFC r196560: Honor the vfs.timestamp_precision sysctl settings for utimes(path, NULL) and similar calls. Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/vfs_syscalls.c Modified: stable/8/sys/kern/vfs_syscalls.c ============================================================================== --- stable/8/sys/kern/vfs_syscalls.c Mon Aug 31 04:19:01 2009 (r196686) +++ stable/8/sys/kern/vfs_syscalls.c Mon Aug 31 09:08:14 2009 (r196687) @@ -3134,8 +3134,7 @@ getutimes(usrtvp, tvpseg, tsp) int error; if (usrtvp == NULL) { - microtime(&tv[0]); - TIMEVAL_TO_TIMESPEC(&tv[0], &tsp[0]); + vfs_timestamp(&tsp[0]); tsp[1] = tsp[0]; } else { if (tvpseg == UIO_SYSSPACE) { From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 09:20:37 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3868106568D; Mon, 31 Aug 2009 09:20:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D1EBC8FC1C; Mon, 31 Aug 2009 09:20:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V9KbQQ022095; Mon, 31 Aug 2009 09:20:37 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V9Kb31022093; Mon, 31 Aug 2009 09:20:37 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200908310920.n7V9Kb31022093@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 31 Aug 2009 09:20:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196688 - in stable/7/sys: . contrib/pf kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 09:20:38 -0000 Author: kib Date: Mon Aug 31 09:20:37 2009 New Revision: 196688 URL: http://svn.freebsd.org/changeset/base/196688 Log: MFC r196560: Honor the vfs.timestamp_precision sysctl settings for utimes(path, NULL) and similar calls. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/vfs_syscalls.c Modified: stable/7/sys/kern/vfs_syscalls.c ============================================================================== --- stable/7/sys/kern/vfs_syscalls.c Mon Aug 31 09:08:14 2009 (r196687) +++ stable/7/sys/kern/vfs_syscalls.c Mon Aug 31 09:20:37 2009 (r196688) @@ -2843,8 +2843,7 @@ getutimes(usrtvp, tvpseg, tsp) int error; if (usrtvp == NULL) { - microtime(&tv[0]); - TIMEVAL_TO_TIMESPEC(&tv[0], &tsp[0]); + vfs_timestamp(&tsp[0]); tsp[1] = tsp[0]; } else { if (tvpseg == UIO_SYSSPACE) { From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 09:44:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D00FF1065676; Mon, 31 Aug 2009 09:44:07 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BCA038FC14; Mon, 31 Aug 2009 09:44:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V9i7aG022663; Mon, 31 Aug 2009 09:44:07 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V9i7TF022661; Mon, 31 Aug 2009 09:44:07 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908310944.n7V9i7TF022661@svn.freebsd.org> From: Marko Zec Date: Mon, 31 Aug 2009 09:44:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196690 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 09:44:07 -0000 Author: zec Date: Mon Aug 31 09:44:07 2009 New Revision: 196690 URL: http://svn.freebsd.org/changeset/base/196690 Log: MFC r196633: Introduce a separate sx lock for protecting lists of vnet sysinit and sysuninit handlers. Previously, sx_vnet, which is a lock designated for protecting the vnet list, was (ab)used for protecting vnet sysinit / sysuninit handler lists as well. Holding exclusively the sx_vnet lock while invoking sysinit and / or sysuninit handlers turned out to be problematic, since some of the handlers may attempt to wake up another thread and wait for it to walk over the vnet list, hence acquire a shared lock on sx_vnet, which in turn leads to a deadlock. Protecting vnet sysinit / sysuninit lists with a separate lock mitigates this issue, which was first observed with flowtable_flush() / flowtable_cleaner() in sys/net/flowtable.c. Reviewed by: rwatson, jhb MFC after: 3 days Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/vnet.c Modified: stable/8/sys/net/vnet.c ============================================================================== --- stable/8/sys/net/vnet.c Mon Aug 31 09:26:04 2009 (r196689) +++ stable/8/sys/net/vnet.c Mon Aug 31 09:44:07 2009 (r196690) @@ -182,14 +182,21 @@ static VNET_DEFINE(char, modspace[VNET_M /* * Global lists of subsystem constructor and destructors for vnets. They are - * registered via VNET_SYSINIT() and VNET_SYSUNINIT(). The lists are - * protected by the vnet_sxlock global lock. + * registered via VNET_SYSINIT() and VNET_SYSUNINIT(). Both lists are + * protected by the vnet_sysinit_sxlock global lock. */ static TAILQ_HEAD(vnet_sysinit_head, vnet_sysinit) vnet_constructors = TAILQ_HEAD_INITIALIZER(vnet_constructors); static TAILQ_HEAD(vnet_sysuninit_head, vnet_sysinit) vnet_destructors = TAILQ_HEAD_INITIALIZER(vnet_destructors); +struct sx vnet_sysinit_sxlock; + +#define VNET_SYSINIT_WLOCK() sx_xlock(&vnet_sysinit_sxlock); +#define VNET_SYSINIT_WUNLOCK() sx_xunlock(&vnet_sysinit_sxlock); +#define VNET_SYSINIT_RLOCK() sx_slock(&vnet_sysinit_sxlock); +#define VNET_SYSINIT_RUNLOCK() sx_sunlock(&vnet_sysinit_sxlock); + struct vnet_data_free { uintptr_t vnd_start; int vnd_len; @@ -228,12 +235,10 @@ vnet_alloc(void) /* Initialize / attach vnet module instances. */ CURVNET_SET_QUIET(vnet); - - sx_xlock(&vnet_sxlock); vnet_sysinit(); CURVNET_RESTORE(); - rw_wlock(&vnet_rwlock); + VNET_LIST_WLOCK(); LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le); VNET_LIST_WUNLOCK(); @@ -253,7 +258,7 @@ vnet_destroy(struct vnet *vnet) VNET_LIST_WLOCK(); LIST_REMOVE(vnet, vnet_le); - rw_wunlock(&vnet_rwlock); + VNET_LIST_WUNLOCK(); CURVNET_SET_QUIET(vnet); @@ -264,8 +269,6 @@ vnet_destroy(struct vnet *vnet) } vnet_sysuninit(); - sx_xunlock(&vnet_sxlock); - CURVNET_RESTORE(); /* @@ -287,6 +290,7 @@ vnet_init_prelink(void *arg) rw_init(&vnet_rwlock, "vnet_rwlock"); sx_init(&vnet_sxlock, "vnet_sxlock"); + sx_init(&vnet_sysinit_sxlock, "vnet_sysinit_sxlock"); LIST_INIT(&vnet_head); } SYSINIT(vnet_init_prelink, SI_SUB_VNET_PRELINK, SI_ORDER_FIRST, @@ -494,7 +498,7 @@ vnet_register_sysinit(void *arg) KASSERT(vs->subsystem > SI_SUB_VNET, ("vnet sysinit too early")); /* Add the constructor to the global list of vnet constructors. */ - sx_xlock(&vnet_sxlock); + VNET_SYSINIT_WLOCK(); TAILQ_FOREACH(vs2, &vnet_constructors, link) { if (vs2->subsystem > vs->subsystem) break; @@ -515,7 +519,7 @@ vnet_register_sysinit(void *arg) vs->func(vs->arg); CURVNET_RESTORE(); } - sx_xunlock(&vnet_sxlock); + VNET_SYSINIT_WUNLOCK(); } void @@ -526,9 +530,9 @@ vnet_deregister_sysinit(void *arg) vs = arg; /* Remove the constructor from the global list of vnet constructors. */ - sx_xlock(&vnet_sxlock); + VNET_SYSINIT_WLOCK(); TAILQ_REMOVE(&vnet_constructors, vs, link); - sx_xunlock(&vnet_sxlock); + VNET_SYSINIT_WUNLOCK(); } void @@ -539,7 +543,7 @@ vnet_register_sysuninit(void *arg) vs = arg; /* Add the destructor to the global list of vnet destructors. */ - sx_xlock(&vnet_sxlock); + VNET_SYSINIT_WLOCK(); TAILQ_FOREACH(vs2, &vnet_destructors, link) { if (vs2->subsystem > vs->subsystem) break; @@ -550,7 +554,7 @@ vnet_register_sysuninit(void *arg) TAILQ_INSERT_BEFORE(vs2, vs, link); else TAILQ_INSERT_TAIL(&vnet_destructors, vs, link); - sx_xunlock(&vnet_sxlock); + VNET_SYSINIT_WUNLOCK(); } void @@ -565,7 +569,7 @@ vnet_deregister_sysuninit(void *arg) * Invoke the destructor on all the existing vnets when it is * deregistered. */ - sx_xlock(&vnet_sxlock); + VNET_SYSINIT_WLOCK(); VNET_FOREACH(vnet) { CURVNET_SET_QUIET(vnet); vs->func(vs->arg); @@ -574,40 +578,42 @@ vnet_deregister_sysuninit(void *arg) /* Remove the destructor from the global list of vnet destructors. */ TAILQ_REMOVE(&vnet_destructors, vs, link); - sx_xunlock(&vnet_sxlock); + VNET_SYSINIT_WUNLOCK(); } /* * Invoke all registered vnet constructors on the current vnet. Used during * vnet construction. The caller is responsible for ensuring the new vnet is - * the current vnet and that the vnet_sxlock lock is locked. + * the current vnet and that the vnet_sysinit_sxlock lock is locked. */ void vnet_sysinit(void) { struct vnet_sysinit *vs; - sx_assert(&vnet_sxlock, SA_LOCKED); + VNET_SYSINIT_RLOCK(); TAILQ_FOREACH(vs, &vnet_constructors, link) { vs->func(vs->arg); } + VNET_SYSINIT_RUNLOCK(); } /* * Invoke all registered vnet destructors on the current vnet. Used during * vnet destruction. The caller is responsible for ensuring the dying vnet - * is the current vnet and that the vnet_sxlock lock is locked. + * the current vnet and that the vnet_sysinit_sxlock lock is locked. */ void vnet_sysuninit(void) { struct vnet_sysinit *vs; - sx_assert(&vnet_sxlock, SA_LOCKED); + VNET_SYSINIT_RLOCK(); TAILQ_FOREACH_REVERSE(vs, &vnet_destructors, vnet_sysuninit_head, link) { vs->func(vs->arg); } + VNET_SYSINIT_RUNLOCK(); } #ifdef DDB From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 09:46:10 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 600A81065679; Mon, 31 Aug 2009 09:46:10 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 44AC58FC14; Mon, 31 Aug 2009 09:46:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V9kADG022783; Mon, 31 Aug 2009 09:46:10 GMT (envelope-from zec@svn.freebsd.org) Received: (from zec@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7V9kAYN022780; Mon, 31 Aug 2009 09:46:10 GMT (envelope-from zec@svn.freebsd.org) Message-Id: <200908310946.n7V9kAYN022780@svn.freebsd.org> From: Marko Zec Date: Mon, 31 Aug 2009 09:46:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196691 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris compat/linprocfs compat/linux contrib/dev/acpica contrib/pf dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 09:46:10 -0000 Author: zec Date: Mon Aug 31 09:46:09 2009 New Revision: 196691 URL: http://svn.freebsd.org/changeset/base/196691 Log: MFC r196635: Fix a few panics in linuxulator + VIMAGE due to curvnet not being set. This change affects only options VIMAGE builds. Reviewed by: julian Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/compat/linprocfs/linprocfs.c stable/8/sys/compat/linux/linux_ioctl.c stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/compat/linprocfs/linprocfs.c ============================================================================== --- stable/8/sys/compat/linprocfs/linprocfs.c Mon Aug 31 09:44:07 2009 (r196690) +++ stable/8/sys/compat/linprocfs/linprocfs.c Mon Aug 31 09:46:09 2009 (r196691) @@ -1085,6 +1085,7 @@ linprocfs_donetdev(PFS_FILL_ARGS) "bytes packets errs drop fifo frame compressed", "bytes packets errs drop fifo frame compressed"); + CURVNET_SET(TD_TO_VNET(curthread)); IFNET_RLOCK(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { linux_ifname(ifp, ifname, sizeof ifname); @@ -1095,6 +1096,7 @@ linprocfs_donetdev(PFS_FILL_ARGS) 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL); } IFNET_RUNLOCK(); + CURVNET_RESTORE(); return (0); } Modified: stable/8/sys/compat/linux/linux_ioctl.c ============================================================================== --- stable/8/sys/compat/linux/linux_ioctl.c Mon Aug 31 09:44:07 2009 (r196690) +++ stable/8/sys/compat/linux/linux_ioctl.c Mon Aug 31 09:46:09 2009 (r196691) @@ -2104,6 +2104,7 @@ ifname_linux_to_bsd(struct thread *td, c return (NULL); index = 0; is_eth = (len == 3 && !strncmp(lxname, "eth", len)) ? 1 : 0; + CURVNET_SET(TD_TO_VNET(td)); IFNET_RLOCK(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { /* @@ -2117,6 +2118,7 @@ ifname_linux_to_bsd(struct thread *td, c break; } IFNET_RUNLOCK(); + CURVNET_RESTORE(); if (ifp != NULL) strlcpy(bsdname, ifp->if_xname, IFNAMSIZ); return (ifp); @@ -2146,6 +2148,7 @@ linux_ifconf(struct thread *td, struct i max_len = MAXPHYS - 1; + CURVNET_SET(TD_TO_VNET(td)); /* handle the 'request buffer size' case */ if (ifc.ifc_buf == PTROUT(NULL)) { ifc.ifc_len = 0; @@ -2157,11 +2160,14 @@ linux_ifconf(struct thread *td, struct i } } error = copyout(&ifc, uifc, sizeof(ifc)); + CURVNET_RESTORE(); return (error); } - if (ifc.ifc_len <= 0) + if (ifc.ifc_len <= 0) { + CURVNET_RESTORE(); return (EINVAL); + } again: /* Keep track of eth interfaces */ @@ -2223,6 +2229,7 @@ again: memcpy(PTRIN(ifc.ifc_buf), sbuf_data(sb), ifc.ifc_len); error = copyout(&ifc, uifc, sizeof(ifc)); sbuf_delete(sb); + CURVNET_RESTORE(); return (error); } From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 10:09:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1D511065676; Mon, 31 Aug 2009 10:09:47 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 7CA718FC29; Mon, 31 Aug 2009 10:09:47 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 021DA46B0C; Mon, 31 Aug 2009 06:09:47 -0400 (EDT) Date: Mon, 31 Aug 2009 11:09:46 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Qing Li In-Reply-To: <200908302242.n7UMgWW2008517@svn.freebsd.org> Message-ID: References: <200908302242.n7UMgWW2008517@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196673 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 10:09:47 -0000 On Sun, 30 Aug 2009, Qing Li wrote: > In ip_output(), the flow-table module must not try to cache L2/L3 > information for interface of IFF_POINTOPOINT or IFF_LOOPBACK type. > Since the L2 information (rt_lle) is invalid for these interface > types, accidental caching attempt will trigger panic when the invalid > rt_lle reference is accessed. > > When installing a new route, or when updating an existing route, the > user supplied gateway address may be an interface address (this is > particularly true for point-to-point interface related modules such > as ppp, if_tun, if_gif). Currently the routing command handler always > set the RTF_GATEWAY flag if the gateway address is given as part of the > command paramters. Therefore the gateway address must be verified against > interface addresses or else the route would be treated as an indirect > route, thus making that route unusable. With this change, can I mark the following two TODO items as done: * RTM_CHANGE in net/rtsock.c can incorrectly set RTF_GATEWAY (QingLi) (in progress) * flowtable mishandles gateway (G) routes on POINT2POINT interfaces (BrianSomers) (in progress) Also, do we believe your last few commits fix the three issues raised by Sato-san in his IPv6 reports: * IPv6 regression on 8.x (QingLi) (in progress) Thanks! Robert N M Watson Computer Laboratory University of Cambridge > > Reviewed by: kmacy, julian, rwatson > Approved by: re > > Modified: > stable/8/sys/ (props changed) > stable/8/sys/amd64/include/xen/ (props changed) > stable/8/sys/cddl/contrib/opensolaris/ (props changed) > stable/8/sys/contrib/dev/acpica/ (props changed) > stable/8/sys/contrib/pf/ (props changed) > stable/8/sys/dev/xen/xenpci/ (props changed) > stable/8/sys/net/flowtable.c > stable/8/sys/net/rtsock.c > > Modified: stable/8/sys/net/flowtable.c > ============================================================================== > --- stable/8/sys/net/flowtable.c Sun Aug 30 22:39:49 2009 (r196672) > +++ stable/8/sys/net/flowtable.c Sun Aug 30 22:42:32 2009 (r196673) > @@ -692,6 +692,12 @@ uncached: > struct rtentry *rt = ro->ro_rt; > struct ifnet *ifp = rt->rt_ifp; > > + if (ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) { > + RTFREE(rt); > + ro->ro_rt = NULL; > + return (ENOENT); > + } > + > if (rt->rt_flags & RTF_GATEWAY) > l3addr = rt->rt_gateway; > else > > Modified: stable/8/sys/net/rtsock.c > ============================================================================== > --- stable/8/sys/net/rtsock.c Sun Aug 30 22:39:49 2009 (r196672) > +++ stable/8/sys/net/rtsock.c Sun Aug 30 22:42:32 2009 (r196673) > @@ -513,6 +513,39 @@ route_output(struct mbuf *m, struct sock > senderr(error); > } > > + /* > + * The given gateway address may be an interface address. > + * For example, issuing a "route change" command on a route > + * entry that was created from a tunnel, and the gateway > + * address given is the local end point. In this case the > + * RTF_GATEWAY flag must be cleared or the destination will > + * not be reachable even though there is no error message. > + */ > + if (info.rti_info[RTAX_GATEWAY] != NULL && > + info.rti_info[RTAX_GATEWAY]->sa_family != AF_LINK) { > + struct route gw_ro; > + > + bzero(&gw_ro, sizeof(gw_ro)); > + gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; > + rtalloc_ign(&gw_ro, 0); > + /* > + * A host route through the loopback interface is > + * installed for each interface adddress. In pre 8.0 > + * releases the interface address of a PPP link type > + * is not reachable locally. This behavior is fixed as > + * part of the new L2/L3 redesign and rewrite work. The > + * signature of this interface address route is the > + * AF_LINK sa_family type of the rt_gateway, and the > + * rt_ifp has the IFF_LOOPBACK flag set. > + */ > + if (gw_ro.ro_rt != NULL && > + gw_ro.ro_rt->rt_gateway->sa_family == AF_LINK && > + gw_ro.ro_rt->rt_ifp->if_flags & IFF_LOOPBACK) > + info.rti_flags &= ~RTF_GATEWAY; > + if (gw_ro.ro_rt != NULL) > + RTFREE(gw_ro.ro_rt); > + } > + > switch (rtm->rtm_type) { > struct rtentry *saved_nrt; > > @@ -714,7 +747,7 @@ route_output(struct mbuf *m, struct sock > RT_UNLOCK(rt); > senderr(error); > } > - rt->rt_flags |= RTF_GATEWAY; > + rt->rt_flags |= (RTF_GATEWAY & info.rti_flags); > } > if (info.rti_ifa != NULL && > info.rti_ifa != rt->rt_ifa) { > From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 10:17:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F31D1065670; Mon, 31 Aug 2009 10:17:36 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 677808FC1D; Mon, 31 Aug 2009 10:17:36 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 1569546B2D; Mon, 31 Aug 2009 06:17:36 -0400 (EDT) Date: Mon, 31 Aug 2009 11:17:35 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Qing Li In-Reply-To: <200908310018.n7V0IIC1010643@svn.freebsd.org> Message-ID: References: <200908310018.n7V0IIC1010643@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196679 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 10:17:36 -0000 University of Cambridge On Mon, 31 Aug 2009, Qing Li wrote: > As part of r196609, a call to "rtalloc" did not take the fib into > account. So call the appropriate "rtalloc_ign_fib()" instead of > calling "rtalloc_ign()". > > Reviewed by: pointed out by bz > Approved by: re I don't have this in my list of re-approved merges. Are you sure this change was approved by re? Robert N M Watson Computer Laboratory University of Cambridge > > Modified: > stable/8/sys/ (props changed) > stable/8/sys/amd64/include/xen/ (props changed) > stable/8/sys/cddl/contrib/opensolaris/ (props changed) > stable/8/sys/contrib/dev/acpica/ (props changed) > stable/8/sys/contrib/pf/ (props changed) > stable/8/sys/dev/xen/xenpci/ (props changed) > stable/8/sys/net/rtsock.c > > Modified: stable/8/sys/net/rtsock.c > ============================================================================== > --- stable/8/sys/net/rtsock.c Mon Aug 31 00:14:37 2009 (r196678) > +++ stable/8/sys/net/rtsock.c Mon Aug 31 00:18:17 2009 (r196679) > @@ -527,7 +527,7 @@ route_output(struct mbuf *m, struct sock > > bzero(&gw_ro, sizeof(gw_ro)); > gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; > - rtalloc_ign(&gw_ro, 0); > + rtalloc_ign_fib(&gw_ro, 0, so->so_fibnum); > /* > * A host route through the loopback interface is > * installed for each interface adddress. In pre 8.0 > From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 11:54:14 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E8451065672; Mon, 31 Aug 2009 11:54:14 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0D9B98FC0C; Mon, 31 Aug 2009 11:54:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VBsDK3026598; Mon, 31 Aug 2009 11:54:13 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7VBsDMP026596; Mon, 31 Aug 2009 11:54:13 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200908311154.n7VBsDMP026596@svn.freebsd.org> From: John Baldwin Date: Mon, 31 Aug 2009 11:54:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196693 - stable/7/sys/ufs/ufs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 11:54:14 -0000 Author: jhb Date: Mon Aug 31 11:54:13 2009 New Revision: 196693 URL: http://svn.freebsd.org/changeset/base/196693 Log: MFC a part of 191990: Fix compile of UFS_EXTATTR without UFS_EXTATTR_AUTOSTART. PR: kern/138350 Modified: stable/7/sys/ufs/ufs/ufs_extattr.c Modified: stable/7/sys/ufs/ufs/ufs_extattr.c ============================================================================== --- stable/7/sys/ufs/ufs/ufs_extattr.c Mon Aug 31 10:20:52 2009 (r196692) +++ stable/7/sys/ufs/ufs/ufs_extattr.c Mon Aug 31 11:54:13 2009 (r196693) @@ -93,8 +93,10 @@ static int ufs_extattr_set(struct vnode struct thread *td); static int ufs_extattr_rm(struct vnode *vp, int attrnamespace, const char *name, struct ucred *cred, struct thread *td); +#ifdef UFS_EXTATTR_AUTOSTART static int ufs_extattr_autostart_locked(struct mount *mp, struct thread *td); +#endif static int ufs_extattr_start_locked(struct ufsmount *ump, struct thread *td); From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 12:25:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CF27106568B; Mon, 31 Aug 2009 12:25:05 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3A2C58FC1E; Mon, 31 Aug 2009 12:25:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VCP5ND027394; Mon, 31 Aug 2009 12:25:05 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7VCP5mr027392; Mon, 31 Aug 2009 12:25:05 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200908311225.n7VCP5mr027392@svn.freebsd.org> From: Rui Paulo Date: Mon, 31 Aug 2009 12:25:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196694 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/asmc dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 12:25:05 -0000 Author: rpaulo Date: Mon Aug 31 12:25:04 2009 New Revision: 196694 URL: http://svn.freebsd.org/changeset/base/196694 Log: MFC r196455: Make dev.asmc.N.light.control writable by everyone. Submitted by: Patrick Lamaiziere Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/asmc/asmc.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/asmc/asmc.c ============================================================================== --- stable/8/sys/dev/asmc/asmc.c Mon Aug 31 11:54:13 2009 (r196693) +++ stable/8/sys/dev/asmc/asmc.c Mon Aug 31 12:25:04 2009 (r196694) @@ -419,7 +419,8 @@ asmc_attach(device_t dev) SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_light_tree), - OID_AUTO, "control", CTLTYPE_INT | CTLFLAG_RW, + OID_AUTO, "control", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY, dev, 0, model->smc_light_control, "I", "Keyboard backlight brightness control"); } From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 13:02:22 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09144106566C; Mon, 31 Aug 2009 13:02:22 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB9528FC1E; Mon, 31 Aug 2009 13:02:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VD2LYo028261; Mon, 31 Aug 2009 13:02:21 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7VD2Lg8028259; Mon, 31 Aug 2009 13:02:21 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <200908311302.n7VD2Lg8028259@svn.freebsd.org> From: Colin Percival Date: Mon, 31 Aug 2009 13:02:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196695 - stable/8/usr.bin/look X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 13:02:22 -0000 Author: cperciva Date: Mon Aug 31 13:02:21 2009 New Revision: 196695 URL: http://svn.freebsd.org/changeset/base/196695 Log: MFC r196558: Don't try to mmap the contents of empty files. This behaviour was harmless prior to r195693, when mmap(2) changed from silently ignoring requests for mapping zero bytes to returning EINVAL; this commit can be seen as adjusting for the change in mmap(2) in order to make look(1) act like it did previously. Reviewed by: jhb Approved by: re (kib) Modified: stable/8/usr.bin/look/ (props changed) stable/8/usr.bin/look/look.c Modified: stable/8/usr.bin/look/look.c ============================================================================== --- stable/8/usr.bin/look/look.c Mon Aug 31 12:25:04 2009 (r196694) +++ stable/8/usr.bin/look/look.c Mon Aug 31 13:02:21 2009 (r196695) @@ -140,6 +140,10 @@ main(int argc, char *argv[]) err(2, "%s", file); if (sb.st_size > SIZE_T_MAX) errx(2, "%s: %s", file, strerror(EFBIG)); + if (sb.st_size == 0) { + close(fd); + continue; + } if ((front = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) err(2, "%s", file); back = front + sb.st_size; From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 14:13:46 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 282681065670; Mon, 31 Aug 2009 14:13:46 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 151A18FC1F; Mon, 31 Aug 2009 14:13:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VEDjIx030007; Mon, 31 Aug 2009 14:13:45 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7VEDj61030005; Mon, 31 Aug 2009 14:13:45 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <200908311413.n7VEDj61030005@svn.freebsd.org> From: Jamie Gritton Date: Mon, 31 Aug 2009 14:13:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196699 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 14:13:46 -0000 Author: jamie Date: Mon Aug 31 14:13:45 2009 New Revision: 196699 URL: http://svn.freebsd.org/changeset/base/196699 Log: MFC r196592: Fix a LOR between allprison_lock and vnode locks by releasing allprison_lock before releasing a prison's root vnode. PR: kern/138004 Reviewed by: kib Approved by: re (rwatson), bz (mentor) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/kern_jail.c Modified: stable/8/sys/kern/kern_jail.c ============================================================================== --- stable/8/sys/kern/kern_jail.c Mon Aug 31 14:06:59 2009 (r196698) +++ stable/8/sys/kern/kern_jail.c Mon Aug 31 14:13:45 2009 (r196699) @@ -2453,7 +2453,7 @@ prison_deref(struct prison *pr, int flag ppr = pr->pr_parent; for (tpr = ppr; tpr != NULL; tpr = tpr->pr_parent) tpr->pr_childcount--; - sx_downgrade(&allprison_lock); + sx_xunlock(&allprison_lock); #ifdef VIMAGE if (pr->pr_vnet != ppr->pr_vnet) @@ -2479,7 +2479,7 @@ prison_deref(struct prison *pr, int flag /* Removing a prison frees a reference on its parent. */ pr = ppr; mtx_lock(&pr->pr_mtx); - flags = PD_DEREF | PD_LIST_SLOCKED; + flags = PD_DEREF; } } From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 15:43:48 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E41E31065672 for ; Mon, 31 Aug 2009 15:43:48 +0000 (UTC) (envelope-from qingli@speakeasy.net) Received: from mail2.sea5.speakeasy.net (mail2.sea5.speakeasy.net [69.17.117.4]) by mx1.freebsd.org (Postfix) with ESMTP id BD9F58FC20 for ; Mon, 31 Aug 2009 15:43:48 +0000 (UTC) Received: (qmail 2274 invoked from network); 31 Aug 2009 15:17:08 -0000 Received: from dsl081-051-206.sfo1.dsl.speakeasy.net (HELO qm8nwm5acsx) ([64.81.51.206]) (envelope-sender ) by mail2.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 31 Aug 2009 15:17:08 -0000 From: "Qing Li" To: "'Robert Watson'" , "'Qing Li'" Date: Mon, 31 Aug 2009 08:17:38 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: Thread-Index: AcoqIy2OtzufaA5mR+Wam5y5Yavn1AAKuEIg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Message-Id: <20090831154348.E41E31065672@hub.freebsd.org> Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: RE: svn commit: r196673 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 15:43:49 -0000 > > With this change, can I mark the following two TODO items as done: > > * RTM_CHANGE in net/rtsock.c can incorrectly set > RTF_GATEWAY (QingLi) (in > progress) > * flowtable mishandles gateway (G) routes on POINT2POINT interfaces > (BrianSomers) (in progress) > AFAIK, Yes. > > Also, do we believe your last few commits fix the three > issues raised by Sato-san in his IPv6 reports: > > * IPv6 regression on 8.x (QingLi) (in progress) One is reported as remaining, which I will investigate today and hope to take care of it soon. -- Qing From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 15:45:12 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DCF91065696 for ; Mon, 31 Aug 2009 15:45:12 +0000 (UTC) (envelope-from qingli@speakeasy.net) Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net [69.17.117.10]) by mx1.freebsd.org (Postfix) with ESMTP id 680E78FC27 for ; Mon, 31 Aug 2009 15:45:12 +0000 (UTC) Received: (qmail 8909 invoked from network); 31 Aug 2009 15:18:32 -0000 Received: from dsl081-051-206.sfo1.dsl.speakeasy.net (HELO qm8nwm5acsx) ([64.81.51.206]) (envelope-sender ) by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 31 Aug 2009 15:18:32 -0000 From: "Qing Li" To: "'Robert Watson'" , "'Qing Li'" Date: Mon, 31 Aug 2009 08:19:03 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: Thread-Index: AcoqJENQEoC9CBq1RmS0J3C8WCevJwAKfqwg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Message-Id: <20090831154512.8DCF91065696@hub.freebsd.org> Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: RE: svn commit: r196679 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 15:45:12 -0000 > > On Mon, 31 Aug 2009, Qing Li wrote: > > > As part of r196609, a call to "rtalloc" did not take the > fib into > > account. So call the appropriate "rtalloc_ign_fib()" instead of > > calling "rtalloc_ign()". > > > > Reviewed by: pointed out by bz > > Approved by: re > > I don't have this in my list of re-approved merges. Are you > sure this change was approved by re? > >From "Kostik Belousov": "There was (unhandled) note from Bjoern about interaction with FIB. Patch is approved, but please take care of that note." I assume it's fine. -- Qing From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 19:07:20 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F36BD106566B; Mon, 31 Aug 2009 19:07:19 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF8718FC12; Mon, 31 Aug 2009 19:07:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VJ7JHo036302; Mon, 31 Aug 2009 19:07:19 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7VJ7J9Z036296; Mon, 31 Aug 2009 19:07:19 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200908311907.n7VJ7J9Z036296@svn.freebsd.org> From: John Baldwin Date: Mon, 31 Aug 2009 19:07:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196708 - in stable/7: share/man/man9 sys sys/conf sys/contrib/pf sys/kern sys/sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 19:07:20 -0000 Author: jhb Date: Mon Aug 31 19:07:19 2009 New Revision: 196708 URL: http://svn.freebsd.org/changeset/base/196708 Log: MFC 193260 and 196417: Add a simple API to manage scatter/gather lists of phyiscal addresses. Each list describes a logical memory object that is backed by one or more physical address ranges. To minimize locking, the sglist objects themselves are immutable once they are shared. Added: stable/7/share/man/man9/sglist.9 - copied, changed from r193260, head/share/man/man9/sglist.9 stable/7/sys/kern/subr_sglist.c - copied, changed from r193260, head/sys/kern/subr_sglist.c stable/7/sys/sys/sglist.h - copied unchanged from r193260, head/sys/sys/sglist.h Modified: stable/7/share/man/man9/ (props changed) stable/7/share/man/man9/Makefile stable/7/sys/ (props changed) stable/7/sys/conf/files stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/share/man/man9/Makefile ============================================================================== --- stable/7/share/man/man9/Makefile Mon Aug 31 18:41:13 2009 (r196707) +++ stable/7/share/man/man9/Makefile Mon Aug 31 19:07:19 2009 (r196708) @@ -210,6 +210,7 @@ MAN= accept_filter.9 \ selrecord.9 \ sema.9 \ sf_buf.9 \ + sglist.9 \ signal.9 \ sleep.9 \ sleepqueue.9 \ @@ -983,6 +984,24 @@ MLINKS+=sf_buf.9 sf_buf_alloc.9 \ sf_buf.9 sf_buf_free.9 \ sf_buf.9 sf_buf_kva.9 \ sf_buf.9 sf_buf_page.9 +MLINKS+=sglist.9 sglist_alloc.9 \ + sglist.9 sglist_append.9 \ + sglist.9 sglist_append_mbuf.9 \ + sglist.9 sglist_append_phys.9 \ + sglist.9 sglist_append_uio.9 \ + sglist.9 sglist_append_user.9 \ + sglist.9 sglist_build.9 \ + sglist.9 sglist_clone.9 \ + sglist.9 sglist_consume_uio.9 \ + sglist.9 sglist_count.9 \ + sglist.9 sglist_free.9 \ + sglist.9 sglist_hold.9 \ + sglist.9 sglist_init.9 \ + sglist.9 sglist_join.9 \ + sglist.9 sglist_length.9 \ + sglist.9 sglist_reset.9 \ + sglist.9 sglist_slice.9 \ + sglist.9 sglist_split.9 MLINKS+=signal.9 cursig.9 \ signal.9 execsigs.9 \ signal.9 issignal.9 \ Copied and modified: stable/7/share/man/man9/sglist.9 (from r193260, head/share/man/man9/sglist.9) ============================================================================== --- head/share/man/man9/sglist.9 Mon Jun 1 20:35:39 2009 (r193260, copy source) +++ stable/7/share/man/man9/sglist.9 Mon Aug 31 19:07:19 2009 (r196708) @@ -191,6 +191,8 @@ Specifically, the family of routines can be used to append the physical address ranges described by an object to the end of a scatter/gather list. All of these routines return 0 on success or an error on failure. +If a request to append an address range to a scatter/gather list fails, +the scatter/gather list will remain unchanged. .Pp The .Nm sglist_append @@ -445,6 +447,7 @@ There are not enough available segments to append the physical address ranges from .Fa second . .El +.Pp The .Nm sglist_slice function returns the following errors on failure: @@ -470,6 +473,7 @@ list in .Fa *slice to describe the requested physical address ranges. .El +.Pp The .Nm sglist_split function returns the following errors on failure: Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Mon Aug 31 18:41:13 2009 (r196707) +++ stable/7/sys/conf/files Mon Aug 31 19:07:19 2009 (r196708) @@ -1630,6 +1630,7 @@ kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_resource.c standard kern/kern_rwlock.c standard +kern/kern_sdt.c optional kdtrace_hooks kern/kern_sema.c standard kern/kern_shutdown.c standard kern/kern_sig.c standard @@ -1683,7 +1684,7 @@ kern/subr_rman.c standard kern/subr_rtc.c optional genclock kern/subr_sbuf.c standard kern/subr_scanf.c standard -kern/kern_sdt.c optional kdtrace_hooks +kern/subr_sglist.c standard kern/subr_sleepqueue.c standard kern/subr_smp.c standard kern/subr_stack.c optional ddb | stack Copied and modified: stable/7/sys/kern/subr_sglist.c (from r193260, head/sys/kern/subr_sglist.c) ============================================================================== --- head/sys/kern/subr_sglist.c Mon Jun 1 20:35:39 2009 (r193260, copy source) +++ stable/7/sys/kern/subr_sglist.c Mon Aug 31 19:07:19 2009 (r196708) @@ -48,6 +48,32 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_SGLIST, "sglist", "scatter/gather lists"); /* + * Convenience macros to save the state of an sglist so it can be restored + * if an append attempt fails. Since sglist's only grow we only need to + * save the current count of segments and the length of the ending segment. + * Earlier segments will not be changed by an append, and the only change + * that can occur to the ending segment is that it can be extended. + */ +struct sgsave { + u_short sg_nseg; + size_t ss_len; +}; + +#define SGLIST_SAVE(sg, sgsave) do { \ + (sgsave).sg_nseg = (sg)->sg_nseg; \ + if ((sgsave).sg_nseg > 0) \ + (sgsave).ss_len = (sg)->sg_segs[(sgsave).sg_nseg - 1].ss_len; \ + else \ + (sgsave).ss_len = 0; \ +} while (0) + +#define SGLIST_RESTORE(sg, sgsave) do { \ + (sg)->sg_nseg = (sgsave).sg_nseg; \ + if ((sgsave).sg_nseg > 0) \ + (sg)->sg_segs[(sgsave).sg_nseg - 1].ss_len = (sgsave).ss_len; \ +} while (0) + +/* * Append a single (paddr, len) to a sglist. sg is the list and ss is * the current segment in the list. If we run out of segments then * EFBIG will be returned. @@ -62,10 +88,8 @@ _sglist_append_range(struct sglist *sg, if (ss->ss_paddr + ss->ss_len == paddr) ss->ss_len += len; else { - if (sg->sg_nseg == sg->sg_maxseg) { - sg->sg_nseg = 0; + if (sg->sg_nseg == sg->sg_maxseg) return (EFBIG); - } ss++; ss->ss_paddr = paddr; ss->ss_len = len; @@ -107,26 +131,33 @@ _sglist_append_buf(struct sglist *sg, vo ss->ss_paddr = paddr; ss->ss_len = seglen; sg->sg_nseg = 1; - error = 0; } else { ss = &sg->sg_segs[sg->sg_nseg - 1]; error = _sglist_append_range(sg, &ss, paddr, seglen); + if (error) + return (error); } + vaddr += seglen; + len -= seglen; + if (donep) + *donep += seglen; - while (error == 0 && len > seglen) { - vaddr += seglen; - len -= seglen; - if (donep) - *donep += seglen; + while (len > 0) { seglen = MIN(len, PAGE_SIZE); if (pmap != NULL) paddr = pmap_extract(pmap, vaddr); else paddr = pmap_kextract(vaddr); error = _sglist_append_range(sg, &ss, paddr, seglen); + if (error) + return (error); + vaddr += seglen; + len -= seglen; + if (donep) + *donep += seglen; } - return (error); + return (0); } /* @@ -195,10 +226,16 @@ sglist_free(struct sglist *sg) int sglist_append(struct sglist *sg, void *buf, size_t len) { + struct sgsave save; + int error; if (sg->sg_maxseg == 0) return (EINVAL); - return (_sglist_append_buf(sg, buf, len, NULL, NULL)); + SGLIST_SAVE(sg, save); + error = _sglist_append_buf(sg, buf, len, NULL, NULL); + if (error) + SGLIST_RESTORE(sg, save); + return (error); } /* @@ -209,6 +246,8 @@ int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, size_t len) { struct sglist_seg *ss; + struct sgsave save; + int error; if (sg->sg_maxseg == 0) return (EINVAL); @@ -222,7 +261,11 @@ sglist_append_phys(struct sglist *sg, vm return (0); } ss = &sg->sg_segs[sg->sg_nseg - 1]; - return (_sglist_append_range(sg, &ss, paddr, len)); + SGLIST_SAVE(sg, save); + error = _sglist_append_range(sg, &ss, paddr, len); + if (error) + SGLIST_RESTORE(sg, save); + return (error); } /* @@ -233,6 +276,7 @@ sglist_append_phys(struct sglist *sg, vm int sglist_append_mbuf(struct sglist *sg, struct mbuf *m0) { + struct sgsave save; struct mbuf *m; int error; @@ -240,11 +284,14 @@ sglist_append_mbuf(struct sglist *sg, st return (EINVAL); error = 0; + SGLIST_SAVE(sg, save); for (m = m0; m != NULL; m = m->m_next) { if (m->m_len > 0) { error = sglist_append(sg, m->m_data, m->m_len); - if (error) + if (error) { + SGLIST_RESTORE(sg, save); return (error); + } } } return (0); @@ -258,11 +305,17 @@ sglist_append_mbuf(struct sglist *sg, st int sglist_append_user(struct sglist *sg, void *buf, size_t len, struct thread *td) { + struct sgsave save; + int error; if (sg->sg_maxseg == 0) return (EINVAL); - return (_sglist_append_buf(sg, buf, len, - vmspace_pmap(td->td_proc->p_vmspace), NULL)); + SGLIST_SAVE(sg, save); + error = _sglist_append_buf(sg, buf, len, + vmspace_pmap(td->td_proc->p_vmspace), NULL); + if (error) + SGLIST_RESTORE(sg, save); + return (error); } /* @@ -274,6 +327,7 @@ int sglist_append_uio(struct sglist *sg, struct uio *uio) { struct iovec *iov; + struct sgsave save; size_t resid, minlen; pmap_t pmap; int error, i; @@ -292,6 +346,7 @@ sglist_append_uio(struct sglist *sg, str pmap = NULL; error = 0; + SGLIST_SAVE(sg, save); for (i = 0; i < uio->uio_iovcnt && resid != 0; i++) { /* * Now at the first iovec to load. Load each iovec @@ -301,8 +356,10 @@ sglist_append_uio(struct sglist *sg, str if (minlen > 0) { error = _sglist_append_buf(sg, iov[i].iov_base, minlen, pmap, NULL); - if (error) + if (error) { + SGLIST_RESTORE(sg, save); return (error); + } resid -= minlen; } } @@ -397,6 +454,7 @@ sglist_clone(struct sglist *sg, int mfla new = sglist_alloc(sg->sg_maxseg, mflags); if (new == NULL) return (NULL); + new->sg_nseg = sg->sg_nseg; bcopy(sg->sg_segs, new->sg_segs, sizeof(struct sglist_seg) * sg->sg_nseg); return (new); Copied: stable/7/sys/sys/sglist.h (from r193260, head/sys/sys/sglist.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/sys/sglist.h Mon Aug 31 19:07:19 2009 (r196708, copy of r193260, head/sys/sys/sglist.h) @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 2008 Yahoo!, Inc. + * All rights reserved. + * Written by: John Baldwin + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * A scatter/gather list describes a group of physical address ranges. + * Each physical address range consists of a starting address and a + * length. + */ + +#ifndef __SGLIST_H__ +#define __SGLIST_H__ + +#include + +struct sglist_seg { + vm_paddr_t ss_paddr; + size_t ss_len; +}; + +struct sglist { + struct sglist_seg *sg_segs; + int sg_refs; + u_short sg_nseg; + u_short sg_maxseg; +}; + +struct mbuf; +struct uio; + +static __inline void +sglist_init(struct sglist *sg, u_short maxsegs, struct sglist_seg *segs) +{ + + sg->sg_segs = segs; + sg->sg_nseg = 0; + sg->sg_maxseg = maxsegs; + refcount_init(&sg->sg_refs, 1); +} + +static __inline void +sglist_reset(struct sglist *sg) +{ + + sg->sg_nseg = 0; +} + +static __inline struct sglist * +sglist_hold(struct sglist *sg) +{ + + refcount_acquire(&sg->sg_refs); + return (sg); +} + +struct sglist *sglist_alloc(int nsegs, int mflags); +int sglist_append(struct sglist *sg, void *buf, size_t len); +int sglist_append_mbuf(struct sglist *sg, struct mbuf *m0); +int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, + size_t len); +int sglist_append_uio(struct sglist *sg, struct uio *uio); +int sglist_append_user(struct sglist *sg, void *buf, size_t len, + struct thread *td); +struct sglist *sglist_build(void *buf, size_t len, int mflags); +struct sglist *sglist_clone(struct sglist *sg, int mflags); +int sglist_consume_uio(struct sglist *sg, struct uio *uio, int resid); +int sglist_count(void *buf, size_t len); +void sglist_free(struct sglist *sg); +int sglist_join(struct sglist *first, struct sglist *second); +size_t sglist_length(struct sglist *sg); +int sglist_slice(struct sglist *original, struct sglist **slice, + size_t offset, size_t length, int mflags); +int sglist_split(struct sglist *original, struct sglist **head, + size_t length, int mflags); + +#endif /* !__SGLIST_H__ */ From owner-svn-src-stable@FreeBSD.ORG Mon Aug 31 19:16:59 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D9271065696; Mon, 31 Aug 2009 19:16:59 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1A9078FC16; Mon, 31 Aug 2009 19:16:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7VJGwcS036560; Mon, 31 Aug 2009 19:16:58 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7VJGwPN036558; Mon, 31 Aug 2009 19:16:58 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200908311916.n7VJGwPN036558@svn.freebsd.org> From: Marius Strobl Date: Mon, 31 Aug 2009 19:16:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196709 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2009 19:16:59 -0000 Author: marius Date: Mon Aug 31 19:16:58 2009 New Revision: 196709 URL: http://svn.freebsd.org/changeset/base/196709 Log: Add a temporary workaround which just lets init die instead of causing a panic if it is killed due to a unsolved stack overflow seen very late during shutdown on sparc64 when the gmirror worker process exists, which is a regression introduced in 8.0. Reviewed by: kib Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/kern_exit.c Modified: stable/8/sys/kern/kern_exit.c ============================================================================== --- stable/8/sys/kern/kern_exit.c Mon Aug 31 19:07:19 2009 (r196708) +++ stable/8/sys/kern/kern_exit.c Mon Aug 31 19:16:58 2009 (r196709) @@ -131,7 +131,12 @@ exit1(struct thread *td, int rv) mtx_assert(&Giant, MA_NOTOWNED); p = td->td_proc; - if (p == initproc) { + /* + * XXX in case we're rebooting we just let init die in order to + * work around an unsolved stack overflow seen very late during + * shutdown on sparc64 when the gmirror worker process exists. + */ + if (p == initproc && rebooting == 0) { printf("init died (signal %d, exit %d)\n", WTERMSIG(rv), WEXITSTATUS(rv)); panic("Going nowhere without my init!"); From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 11:13:32 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07ECC10656C0; Tue, 1 Sep 2009 11:13:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E0DB98FC13; Tue, 1 Sep 2009 11:13:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81BDVZK058933; Tue, 1 Sep 2009 11:13:31 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81BDVOq058931; Tue, 1 Sep 2009 11:13:31 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200909011113.n81BDVOq058931@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 Sep 2009 11:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196729 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/siis dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 11:13:32 -0000 Author: mav Date: Tue Sep 1 11:13:31 2009 New Revision: 196729 URL: http://svn.freebsd.org/changeset/base/196729 Log: MFC r196655: Update siis driver: - Add SNTF support. - Do not report meaningless transport/protocol versions. Approved by: re (ATA-CAM blanket) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/siis/siis.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/siis/siis.c ============================================================================== --- stable/8/sys/dev/siis/siis.c Tue Sep 1 06:15:50 2009 (r196728) +++ stable/8/sys/dev/siis/siis.c Tue Sep 1 11:13:31 2009 (r196729) @@ -647,6 +647,30 @@ siis_slotsfree(device_t dev) } static void +siis_notify_events(device_t dev) +{ + struct siis_channel *ch = device_get_softc(dev); + struct cam_path *dpath; + u_int32_t status; + int i; + + status = ATA_INL(ch->r_mem, SIIS_P_SNTF); + ATA_OUTL(ch->r_mem, SIIS_P_SNTF, status); + if (bootverbose) + device_printf(dev, "SNTF 0x%04x\n", status); + for (i = 0; i < 16; i++) { + if ((status & (1 << i)) == 0) + continue; + if (xpt_create_path(&dpath, NULL, + xpt_path_path_id(ch->path), i, 0) == CAM_REQ_CMP) { + xpt_async(AC_SCSI_AEN, dpath, NULL); + xpt_free_path(dpath); + } + } + +} + +static void siis_phy_check_events(device_t dev) { struct siis_channel *ch = device_get_softc(dev); @@ -707,6 +731,9 @@ siis_ch_intr(void *data) /* Process PHY events */ if (istatus & SIIS_P_IX_PHYRDYCHG) siis_phy_check_events(dev); + /* Process NOTIFY events */ + if (istatus & SIIS_P_IX_SDBN) + siis_notify_events(dev); /* Process command errors */ if (istatus & SIIS_P_IX_COMMERR) { estatus = ATA_INL(ch->r_mem, SIIS_P_CMDERR); @@ -1267,7 +1294,6 @@ siis_reset(device_t dev) /* XXX; Commands in loading state. */ siis_end_transaction(&ch->slot[i], SIIS_ERR_INNOCENT); } - ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, SIIS_P_CTL_PME); /* Reset and reconnect PHY, */ if (!siis_sata_phy_reset(dev)) { ch->devices = 0; @@ -1461,9 +1487,9 @@ siisaction(struct cam_sim *sim, union cc uint32_t status; cts->protocol = PROTO_ATA; - cts->protocol_version = SCSI_REV_2; + cts->protocol_version = PROTO_VERSION_UNSPECIFIED; cts->transport = XPORT_SATA; - cts->transport_version = 2; + cts->transport_version = XPORT_VERSION_UNSPECIFIED; cts->proto_specific.valid = 0; cts->xport_specific.sata.valid = 0; if (cts->type == CTS_TYPE_CURRENT_SETTINGS) @@ -1548,9 +1574,9 @@ siisaction(struct cam_sim *sim, union cc strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; - cpi->transport_version = 2; + cpi->transport_version = XPORT_VERSION_UNSPECIFIED; cpi->protocol = PROTO_ATA; - cpi->protocol_version = SCSI_REV_2; + cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->ccb_h.status = CAM_REQ_CMP; cpi->maxio = MAXPHYS; xpt_done(ccb); From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 11:44:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B3820106566B; Tue, 1 Sep 2009 11:44:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9ED438FC13; Tue, 1 Sep 2009 11:44:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81BiUrX060173; Tue, 1 Sep 2009 11:44:30 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81BiUxH060169; Tue, 1 Sep 2009 11:44:30 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200909011144.n81BiUxH060169@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 Sep 2009 11:44:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196731 - in stable/8: share/man/man4 sys sys/amd64/include/xen sys/cddl/contrib/opensolaris sys/contrib/dev/acpica sys/contrib/pf sys/dev/ahci sys/dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 11:44:30 -0000 Author: mav Date: Tue Sep 1 11:44:30 2009 New Revision: 196731 URL: http://svn.freebsd.org/changeset/base/196731 Log: MFC r196656, r196660: Update ahci driver: - Add Command Completion Coalescing support. - Add SNTF support. - Add two more power management modes (4, 5), implemented on driver level. - Fix interface mode setting. - Reduce interface reset time. - Do not report meaningless protocol/transport versions. - Report CAP2 register content. - Some performance optimizations. Approved by: re (ATA-CAM blanket) Modified: stable/8/share/man/man4/ (props changed) stable/8/share/man/man4/ahci.4 stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ahci/ahci.c stable/8/sys/dev/ahci/ahci.h stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/share/man/man4/ahci.4 ============================================================================== --- stable/8/share/man/man4/ahci.4 Tue Sep 1 11:41:51 2009 (r196730) +++ stable/8/share/man/man4/ahci.4 Tue Sep 1 11:44:30 2009 (r196731) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 26, 2009 +.Dd August 24, 2009 .Dt AHCI 4 .Os .Sh NAME @@ -60,6 +60,13 @@ single MSI vector used, if supported (de .It 2 multiple MSI vectors used, if supported; .El +.It Va hint.ahci.X.ccc +controls Command Completion Coalescing (CCC) usage by the specified controller. +Non-zero value enables CCC and defines maximum time (in ms), request can wait +for interrupt, if there are some more requests present on controller queue. +CCC reduces number of context switches on systems with many parallel requests, +but it can decrease disk performance on some workloads due to additional +command latency. .It Va hint.ahcich.X.pm_level controls SATA interface Power Management for specified channel, allowing some power to be saved at the cost of additional command @@ -74,7 +81,15 @@ device is allowed to initiate PM state c host initiates PARTIAL PM state transition every time port becomes idle; .It 3 host initiates SLUMBER PM state transition every time port becomes idle. +.It 4 +driver initiates PARTIAL PM state transition 1ms after port becomes idle; +.It 5 +driver initiates SLUMBER PM state transition 125ms after port becomes idle. .El +Some controllers, such as ICH8, do not implement modes 2 and 3 with NCQ used. +Because of artificial entering latency, performance degradation in modes +4 and 5 is much smaller then in modes 2 and 3. +.Pp Note that interface Power Management is not compatible with device presence detection. You will have to reset bus manually on device hot-plug. Modified: stable/8/sys/dev/ahci/ahci.c ============================================================================== --- stable/8/sys/dev/ahci/ahci.c Tue Sep 1 11:41:51 2009 (r196730) +++ stable/8/sys/dev/ahci/ahci.c Tue Sep 1 11:44:30 2009 (r196731) @@ -63,6 +63,7 @@ static int ahci_suspend(device_t dev); static int ahci_resume(device_t dev); static int ahci_ch_suspend(device_t dev); static int ahci_ch_resume(device_t dev); +static void ahci_ch_pm(void *arg); static void ahci_ch_intr_locked(void *data); static void ahci_ch_intr(void *data); static int ahci_ctlr_reset(device_t dev); @@ -121,9 +122,11 @@ ahci_attach(device_t dev) struct ahci_controller *ctlr = device_get_softc(dev); device_t child; int error, unit, speed; - u_int32_t version, caps; + u_int32_t version; ctlr->dev = dev; + resource_int_value(device_get_name(dev), + device_get_unit(dev), "ccc", &ctlr->ccc); /* if we have a memory BAR(5) we are likely on an AHCI part */ ctlr->r_rid = PCIR_BAR(5); if (!(ctlr->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, @@ -160,41 +163,49 @@ ahci_attach(device_t dev) } /* Announce HW capabilities. */ version = ATA_INL(ctlr->r_mem, AHCI_VS); - caps = ATA_INL(ctlr->r_mem, AHCI_CAP); - speed = (caps & AHCI_CAP_ISS) >> AHCI_CAP_ISS_SHIFT; + ctlr->caps = ATA_INL(ctlr->r_mem, AHCI_CAP); + if (version >= 0x00010020) + ctlr->caps2 = ATA_INL(ctlr->r_mem, AHCI_CAP2); + speed = (ctlr->caps & AHCI_CAP_ISS) >> AHCI_CAP_ISS_SHIFT; device_printf(dev, "AHCI v%x.%02x with %d %sGbps ports, Port Multiplier %s\n", ((version >> 20) & 0xf0) + ((version >> 16) & 0x0f), ((version >> 4) & 0xf0) + (version & 0x0f), - (caps & AHCI_CAP_NPMASK) + 1, + (ctlr->caps & AHCI_CAP_NPMASK) + 1, ((speed == 1) ? "1.5":((speed == 2) ? "3": ((speed == 3) ? "6":"?"))), - (caps & AHCI_CAP_SPM) ? + (ctlr->caps & AHCI_CAP_SPM) ? "supported" : "not supported"); if (bootverbose) { device_printf(dev, "Caps:%s%s%s%s%s%s%s%s %sGbps", - (caps & AHCI_CAP_64BIT) ? " 64bit":"", - (caps & AHCI_CAP_SNCQ) ? " NCQ":"", - (caps & AHCI_CAP_SSNTF) ? " SNTF":"", - (caps & AHCI_CAP_SMPS) ? " MPS":"", - (caps & AHCI_CAP_SSS) ? " SS":"", - (caps & AHCI_CAP_SALP) ? " ALP":"", - (caps & AHCI_CAP_SAL) ? " AL":"", - (caps & AHCI_CAP_SCLO) ? " CLO":"", + (ctlr->caps & AHCI_CAP_64BIT) ? " 64bit":"", + (ctlr->caps & AHCI_CAP_SNCQ) ? " NCQ":"", + (ctlr->caps & AHCI_CAP_SSNTF) ? " SNTF":"", + (ctlr->caps & AHCI_CAP_SMPS) ? " MPS":"", + (ctlr->caps & AHCI_CAP_SSS) ? " SS":"", + (ctlr->caps & AHCI_CAP_SALP) ? " ALP":"", + (ctlr->caps & AHCI_CAP_SAL) ? " AL":"", + (ctlr->caps & AHCI_CAP_SCLO) ? " CLO":"", ((speed == 1) ? "1.5":((speed == 2) ? "3": ((speed == 3) ? "6":"?")))); printf("%s%s%s%s%s%s %dcmd%s%s%s %dports\n", - (caps & AHCI_CAP_SAM) ? " AM":"", - (caps & AHCI_CAP_SPM) ? " PM":"", - (caps & AHCI_CAP_FBSS) ? " FBS":"", - (caps & AHCI_CAP_PMD) ? " PMD":"", - (caps & AHCI_CAP_SSC) ? " SSC":"", - (caps & AHCI_CAP_PSC) ? " PSC":"", - ((caps & AHCI_CAP_NCS) >> AHCI_CAP_NCS_SHIFT) + 1, - (caps & AHCI_CAP_CCCS) ? " CCC":"", - (caps & AHCI_CAP_EMS) ? " EM":"", - (caps & AHCI_CAP_SXS) ? " eSATA":"", - (caps & AHCI_CAP_NPMASK) + 1); + (ctlr->caps & AHCI_CAP_SAM) ? " AM":"", + (ctlr->caps & AHCI_CAP_SPM) ? " PM":"", + (ctlr->caps & AHCI_CAP_FBSS) ? " FBS":"", + (ctlr->caps & AHCI_CAP_PMD) ? " PMD":"", + (ctlr->caps & AHCI_CAP_SSC) ? " SSC":"", + (ctlr->caps & AHCI_CAP_PSC) ? " PSC":"", + ((ctlr->caps & AHCI_CAP_NCS) >> AHCI_CAP_NCS_SHIFT) + 1, + (ctlr->caps & AHCI_CAP_CCCS) ? " CCC":"", + (ctlr->caps & AHCI_CAP_EMS) ? " EM":"", + (ctlr->caps & AHCI_CAP_SXS) ? " eSATA":"", + (ctlr->caps & AHCI_CAP_NPMASK) + 1); + } + if (bootverbose && version >= 0x00010020) { + device_printf(dev, "Caps2:%s%s%s\n", + (ctlr->caps2 & AHCI_CAP2_APST) ? " APST":"", + (ctlr->caps2 & AHCI_CAP2_NVMP) ? " NVMP":"", + (ctlr->caps2 & AHCI_CAP2_BOH) ? " BOH":""); } /* Attach all channels on this controller */ for (unit = 0; unit < ctlr->channels; unit++) { @@ -266,6 +277,21 @@ ahci_ctlr_reset(device_t dev) ATA_OUTL(ctlr->r_mem, AHCI_GHC, AHCI_GHC_AE); /* Clear interrupts */ ATA_OUTL(ctlr->r_mem, AHCI_IS, ATA_INL(ctlr->r_mem, AHCI_IS)); + /* Configure CCC */ + if (ctlr->ccc) { + ATA_OUTL(ctlr->r_mem, AHCI_CCCP, ATA_INL(ctlr->r_mem, AHCI_PI)); + ATA_OUTL(ctlr->r_mem, AHCI_CCCC, + (ctlr->ccc << AHCI_CCCC_TV_SHIFT) | + (4 << AHCI_CCCC_CC_SHIFT) | + AHCI_CCCC_EN); + ctlr->cccv = (ATA_INL(ctlr->r_mem, AHCI_CCCC) & + AHCI_CCCC_INT_MASK) >> AHCI_CCCC_INT_SHIFT; + if (bootverbose) { + device_printf(dev, + "CCC with %dms/4cmd enabled on vector %d\n", + ctlr->ccc, ctlr->cccv); + } + } /* Enable AHCI interrupts */ ATA_OUTL(ctlr->r_mem, AHCI_GHC, ATA_INL(ctlr->r_mem, AHCI_GHC) | AHCI_GHC_IE); @@ -326,7 +352,8 @@ ahci_setup_interrupt(device_t dev) for (i = 0; i < ctlr->numirqs; i++) { ctlr->irqs[i].ctlr = ctlr; ctlr->irqs[i].r_irq_rid = i + (msi ? 1 : 0); - if (ctlr->numirqs == 1 || i >= ctlr->channels) + if (ctlr->numirqs == 1 || i >= ctlr->channels || + (ctlr->ccc && i == ctlr->cccv)) ctlr->irqs[i].mode = AHCI_IRQ_MODE_ALL; else if (i == ctlr->numirqs - 1) ctlr->irqs[i].mode = AHCI_IRQ_MODE_AFTER; @@ -360,11 +387,16 @@ ahci_intr(void *data) void *arg; int unit; - is = ATA_INL(ctlr->r_mem, AHCI_IS); - if (irq->mode == AHCI_IRQ_MODE_ALL) + if (irq->mode == AHCI_IRQ_MODE_ALL) { unit = 0; - else /* AHCI_IRQ_MODE_AFTER */ + if (ctlr->ccc) + is = ctlr->ichannels; + else + is = ATA_INL(ctlr->r_mem, AHCI_IS); + } else { /* AHCI_IRQ_MODE_AFTER */ unit = irq->r_irq_rid - 1; + is = ATA_INL(ctlr->r_mem, AHCI_IS); + } for (; unit < ctlr->channels; unit++) { if ((is & (1 << unit)) != 0 && (arg = ctlr->interrupt[unit].argument)) { @@ -523,10 +555,14 @@ ahci_ch_attach(device_t dev) ch->dev = dev; ch->unit = (intptr_t)device_get_ivars(dev); - ch->caps = ATA_INL(ctlr->r_mem, AHCI_CAP); + ch->caps = ctlr->caps; + ch->caps2 = ctlr->caps2; ch->numslots = ((ch->caps & AHCI_CAP_NCS) >> AHCI_CAP_NCS_SHIFT) + 1, + mtx_init(&ch->mtx, "AHCI channel lock", NULL, MTX_DEF); resource_int_value(device_get_name(dev), device_get_unit(dev), "pm_level", &ch->pm_level); + if (ch->pm_level > 3) + callout_init_mtx(&ch->pm_timer, &ch->mtx, 0); /* Limit speed for my onboard JMicron external port. * It is not eSATA really. */ if (pci_get_devid(ctlr->dev) == 0x2363197b && @@ -536,7 +572,6 @@ ahci_ch_attach(device_t dev) ch->sata_rev = 1; resource_int_value(device_get_name(dev), device_get_unit(dev), "sata_rev", &ch->sata_rev); - mtx_init(&ch->mtx, "AHCI channel lock", NULL, MTX_DEF); rid = ch->unit; if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE))) @@ -584,6 +619,11 @@ ahci_ch_attach(device_t dev) error = ENXIO; goto err3; } + if (ch->pm_level > 3) { + callout_reset(&ch->pm_timer, + (ch->pm_level == 4) ? hz / 1000 : hz / 8, + ahci_ch_pm, dev); + } mtx_unlock(&ch->mtx); return (0); @@ -610,6 +650,8 @@ ahci_ch_detach(device_t dev) cam_sim_free(ch->sim, /*free_devq*/TRUE); mtx_unlock(&ch->mtx); + if (ch->pm_level > 3) + callout_drain(&ch->pm_timer); bus_teardown_intr(dev, ch->r_irq, ch->ih); bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); @@ -661,7 +703,7 @@ ahci_ch_resume(device_t dev) /* Activate the channel and power/spin up device */ ATA_OUTL(ch->r_mem, AHCI_P_CMD, (AHCI_P_CMD_ACTIVE | AHCI_P_CMD_POD | AHCI_P_CMD_SUD | - ((ch->pm_level > 1) ? AHCI_P_CMD_ALPE : 0) | + ((ch->pm_level == 2 || ch->pm_level == 3) ? AHCI_P_CMD_ALPE : 0) | ((ch->pm_level > 2) ? AHCI_P_CMD_ASP : 0 ))); ahci_start_fr(dev); ahci_start(dev); @@ -815,6 +857,7 @@ ahci_slotsfree(device_t dev) for (i = 0; i < ch->numslots; i++) { struct ahci_slot *slot = &ch->slot[i]; + callout_drain(&slot->timeout); if (slot->dma.data_map) { bus_dmamap_destroy(ch->dma.data_tag, slot->dma.data_map); slot->dma.data_map = NULL; @@ -848,6 +891,31 @@ ahci_phy_check_events(device_t dev) } static void +ahci_notify_events(device_t dev) +{ + struct ahci_channel *ch = device_get_softc(dev); + struct cam_path *dpath; + u_int32_t status; + int i; + + status = ATA_INL(ch->r_mem, AHCI_P_SNTF); + if (status == 0) + return; + ATA_OUTL(ch->r_mem, AHCI_P_SNTF, status); + if (bootverbose) + device_printf(dev, "SNTF 0x%04x\n", status); + for (i = 0; i < 16; i++) { + if ((status & (1 << i)) == 0) + continue; + if (xpt_create_path(&dpath, NULL, + xpt_path_path_id(ch->path), i, 0) == CAM_REQ_CMP) { + xpt_async(AC_SCSI_AEN, dpath, NULL); + xpt_free_path(dpath); + } + } +} + +static void ahci_ch_intr_locked(void *data) { device_t dev = (device_t)data; @@ -859,6 +927,23 @@ ahci_ch_intr_locked(void *data) } static void +ahci_ch_pm(void *arg) +{ + device_t dev = (device_t)arg; + struct ahci_channel *ch = device_get_softc(dev); + uint32_t work; + + if (ch->numrslots != 0) + return; + work = ATA_INL(ch->r_mem, AHCI_P_CMD); + if (ch->pm_level == 4) + work |= AHCI_P_CMD_PARTIAL; + else + work |= AHCI_P_CMD_SLUMBER; + ATA_OUTL(ch->r_mem, AHCI_P_CMD, work); +} + +static void ahci_ch_intr(void *data) { device_t dev = (device_t)data; @@ -869,6 +954,8 @@ ahci_ch_intr(void *data) /* Read and clear interrupt statuses. */ istatus = ATA_INL(ch->r_mem, AHCI_P_IS); + if (istatus == 0) + return; ATA_OUTL(ch->r_mem, AHCI_P_IS, istatus); /* Read command statuses. */ cstatus = ATA_INL(ch->r_mem, AHCI_P_CI); @@ -884,17 +971,16 @@ ahci_ch_intr(void *data) // ATA_INL(ch->r_mem, AHCI_P_SERR)); ccs = (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CCS_MASK) >> AHCI_P_CMD_CCS_SHIFT; + err = ch->rslots & (cstatus | sstatus); /* Kick controller into sane state */ ahci_stop(dev); ahci_start(dev); - ok = ch->rslots & ~(cstatus | sstatus); - err = ch->rslots & (cstatus | sstatus); } else { ccs = 0; - ok = ch->rslots & ~(cstatus | sstatus); err = 0; } /* Complete all successfull commands. */ + ok = ch->rslots & ~(cstatus | sstatus); for (i = 0; i < ch->numslots; i++) { if ((ok >> i) & 1) ahci_end_transaction(&ch->slot[i], AHCI_ERR_NONE); @@ -936,6 +1022,9 @@ ahci_ch_intr(void *data) if (ncq_err) ahci_issue_read_log(dev); } + /* Process NOTIFY events */ + if ((istatus & AHCI_P_IX_SDB) && (ch->caps & AHCI_CAP_SSNTF)) + ahci_notify_events(dev); } /* Must be called with channel locked. */ @@ -980,19 +1069,18 @@ ahci_begin_transaction(device_t dev, uni /* Choose empty slot. */ tag = ch->lastslot; - do { - tag++; - if (tag >= ch->numslots) + while (ch->slot[tag].state != AHCI_SLOT_EMPTY) { + if (++tag >= ch->numslots) tag = 0; - if (ch->slot[tag].state == AHCI_SLOT_EMPTY) - break; - } while (tag != ch->lastslot); - if (ch->slot[tag].state != AHCI_SLOT_EMPTY) - device_printf(ch->dev, "ALL SLOTS BUSY!\n"); + KASSERT(tag != ch->lastslot, ("ahci: ALL SLOTS BUSY!")); + } ch->lastslot = tag; /* Occupy chosen slot. */ slot = &ch->slot[tag]; slot->ccb = ccb; + /* Stop PM timer. */ + if (ch->numrslots == 0 && ch->pm_level > 3) + callout_stop(&ch->pm_timer); /* Update channel stats. */ ch->numrslots++; if ((ccb->ccb_h.func_code == XPT_ATA_IO) && @@ -1162,6 +1250,10 @@ ahci_timeout(struct ahci_slot *slot) struct ahci_channel *ch = device_get_softc(dev); int i; + /* Check for stale timeout. */ + if (slot->state != AHCI_SLOT_RUNNING) + return; + device_printf(dev, "Timeout on slot %d\n", slot->slot); /* Kick controller into sane state. */ ahci_stop(ch->dev); @@ -1194,8 +1286,6 @@ ahci_end_transaction(struct ahci_slot *s struct ahci_channel *ch = device_get_softc(dev); union ccb *ccb = slot->ccb; - /* Cancel command execution timeout */ - callout_stop(&slot->timeout); bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map, BUS_DMASYNC_POSTWRITE); /* Read result registers to the result struct @@ -1302,6 +1392,11 @@ ahci_end_transaction(struct ahci_slot *s ahci_begin_transaction(dev, fccb); xpt_release_simq(ch->sim, TRUE); } + /* Start PM timer. */ + if (ch->numrslots == 0 && ch->pm_level > 3) { + callout_schedule(&ch->pm_timer, + (ch->pm_level == 4) ? hz / 1000 : hz / 8); + } } static void @@ -1516,6 +1611,7 @@ static void ahci_reset(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); + struct ahci_controller *ctlr = device_get_softc(device_get_parent(dev)); int i; if (bootverbose) @@ -1562,10 +1658,10 @@ ahci_reset(device_t dev) (AHCI_P_IX_CPD | AHCI_P_IX_TFE | AHCI_P_IX_HBF | AHCI_P_IX_HBD | AHCI_P_IX_IF | AHCI_P_IX_OF | ((ch->pm_level == 0) ? AHCI_P_IX_PRC | AHCI_P_IX_PC : 0) | - AHCI_P_IX_DP | AHCI_P_IX_UF | AHCI_P_IX_SDB | - AHCI_P_IX_DS | AHCI_P_IX_PS | AHCI_P_IX_DHR)); + AHCI_P_IX_DP | AHCI_P_IX_UF | (ctlr->ccc ? 0 : AHCI_P_IX_SDB) | + AHCI_P_IX_DS | AHCI_P_IX_PS | (ctlr->ccc ? 0 : AHCI_P_IX_DHR))); if (bootverbose) - device_printf(dev, "AHCI reset done: devices=%08x\n", ch->devices); + device_printf(dev, "AHCI reset done: device found\n"); /* Tell the XPT about the event */ xpt_async(AC_BUS_RESET, ch->path, NULL); } @@ -1632,6 +1728,13 @@ ahci_sata_connect(struct ahci_channel *c ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) break; + if ((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_OFFLINE) { + if (bootverbose) { + device_printf(ch->dev, "SATA offline status=%08x\n", + status); + } + return (0); + } DELAY(1000); } if (timeout >= 100) { @@ -1664,9 +1767,6 @@ ahci_sata_phy_reset(device_t dev, int qu if (bootverbose) device_printf(dev, "hardware reset ...\n"); - ATA_OUTL(ch->r_mem, AHCI_P_SCTL, ATA_SC_IPM_DIS_PARTIAL | - ATA_SC_IPM_DIS_SLUMBER | ATA_SC_DET_RESET); - DELAY(50000); if (ch->sata_rev == 1) val = ATA_SC_SPD_SPEED_GEN1; else if (ch->sata_rev == 2) @@ -1676,9 +1776,13 @@ ahci_sata_phy_reset(device_t dev, int qu else val = 0; ATA_OUTL(ch->r_mem, AHCI_P_SCTL, + ATA_SC_DET_RESET | val | + ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER); + DELAY(5000); + ATA_OUTL(ch->r_mem, AHCI_P_SCTL, ATA_SC_DET_IDLE | val | ((ch->pm_level > 0) ? 0 : (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER))); - DELAY(50000); + DELAY(5000); return (ahci_sata_connect(ch)); } @@ -1739,9 +1843,9 @@ ahciaction(struct cam_sim *sim, union cc uint32_t status; cts->protocol = PROTO_ATA; - cts->protocol_version = SCSI_REV_2; + cts->protocol_version = PROTO_VERSION_UNSPECIFIED; cts->transport = XPORT_SATA; - cts->transport_version = 2; + cts->transport_version = XPORT_VERSION_UNSPECIFIED; cts->proto_specific.valid = 0; cts->xport_specific.sata.valid = 0; if (cts->type == CTS_TYPE_CURRENT_SETTINGS) @@ -1834,9 +1938,9 @@ ahciaction(struct cam_sim *sim, union cc strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; - cpi->transport_version = 2; + cpi->transport_version = XPORT_VERSION_UNSPECIFIED; cpi->protocol = PROTO_ATA; - cpi->protocol_version = SCSI_REV_2; + cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = MAXPHYS; cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); Modified: stable/8/sys/dev/ahci/ahci.h ============================================================================== --- stable/8/sys/dev/ahci/ahci.h Tue Sep 1 11:41:51 2009 (r196730) +++ stable/8/sys/dev/ahci/ahci.h Tue Sep 1 11:44:30 2009 (r196731) @@ -176,6 +176,21 @@ #define AHCI_PI 0x0c #define AHCI_VS 0x10 +#define AHCI_CCCC 0x14 +#define AHCI_CCCC_TV_MASK 0xffff0000 +#define AHCI_CCCC_TV_SHIFT 16 +#define AHCI_CCCC_CC_MASK 0x0000ff00 +#define AHCI_CCCC_CC_SHIFT 8 +#define AHCI_CCCC_INT_MASK 0x000000f8 +#define AHCI_CCCC_INT_SHIFT 3 +#define AHCI_CCCC_EN 0x00000001 +#define AHCI_CCCP 0x18 + +#define AHCI_CAP2 0x24 +#define AHCI_CAP2_BOH 0x00000001 +#define AHCI_CAP2_NVMP 0x00000002 +#define AHCI_CAP2_APST 0x00000004 + #define AHCI_OFFSET 0x100 #define AHCI_STEP 0x80 @@ -336,6 +351,7 @@ struct ahci_channel { struct cam_sim *sim; struct cam_path *path; uint32_t caps; /* Controller capabilities */ + uint32_t caps2; /* Controller capabilities */ int numslots; /* Number of present slots */ int pm_level; /* power management level */ int sata_rev; /* Maximum allowed SATA generation */ @@ -353,6 +369,7 @@ struct ahci_channel { int lastslot; /* Last used slot */ int taggedtarget; /* Last tagged target */ union ccb *frozen; /* Frozen command */ + struct callout pm_timer; /* Power management events */ }; /* structure describing a AHCI controller */ @@ -371,9 +388,13 @@ struct ahci_controller { #define AHCI_IRQ_MODE_AFTER 1 #define AHCI_IRQ_MODE_ONE 2 } irqs[16]; + uint32_t caps; /* Controller capabilities */ + uint32_t caps2; /* Controller capabilities */ int numirqs; int channels; int ichannels; + int ccc; /* CCC timeout */ + int cccv; /* CCC vector */ struct { void (*function)(void *); void *argument; From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 12:04:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FCE31065679; Tue, 1 Sep 2009 12:04:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7B0618FC15; Tue, 1 Sep 2009 12:04:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81C4h1x060771; Tue, 1 Sep 2009 12:04:43 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81C4hL0060765; Tue, 1 Sep 2009 12:04:43 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200909011204.n81C4hL0060765@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 Sep 2009 12:04:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196732 - in stable/8: sbin/camcontrol sys sys/amd64/include/xen sys/cam/ata sys/cddl/contrib/opensolaris sys/contrib/dev/acpica sys/contrib/pf sys/dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 12:04:43 -0000 Author: mav Date: Tue Sep 1 12:04:43 2009 New Revision: 196732 URL: http://svn.freebsd.org/changeset/base/196732 Log: MFC r196657: ATA_FLUSHCACHE is a 28bit format command, not 48. MFC r196658: Improve camcontrol ATA support: - Tune protocol version reporting, - Add supported DMA/PIO modes reporting. - Fix IDENTIFY request for ATAPI devices. - Remove confusing "-" for NCQ status. MFC r196659: Short ATA command format has 28bit address, not 36bit. Rename ata_36bit_cmd() into ata_28bit_cmd(), while it didn't become legacy. Approved by: re (ATA-CAM blanket) Modified: stable/8/sbin/camcontrol/ (props changed) stable/8/sbin/camcontrol/camcontrol.c stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cam/ata/ata_all.c stable/8/sys/cam/ata/ata_all.h stable/8/sys/cam/ata/ata_da.c stable/8/sys/cam/ata/ata_xpt.c stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/8/sbin/camcontrol/camcontrol.c Tue Sep 1 11:44:30 2009 (r196731) +++ stable/8/sbin/camcontrol/camcontrol.c Tue Sep 1 12:04:43 2009 (r196732) @@ -206,6 +206,7 @@ static void cts_print(struct cam_device struct ccb_trans_settings *cts); static void cpi_print(struct ccb_pathinq *cpi); static int get_cpi(struct cam_device *device, struct ccb_pathinq *cpi); +static int get_cgd(struct cam_device *device, struct ccb_getdev *cgd); static int get_print_cts(struct cam_device *device, int user_settings, int quiet, struct ccb_trans_settings *cts); static int ratecontrol(struct cam_device *device, int retry_count, @@ -1015,17 +1016,18 @@ atacapprint(struct ata_params *parm) ((u_int64_t)parm->lba_size48_4 << 48); printf("\n"); - printf("Protocol "); + printf("protocol "); + printf("ATA/ATAPI-%d", ata_version(parm->version_major)); if (parm->satacapabilities && parm->satacapabilities != 0xffff) { if (parm->satacapabilities & ATA_SATA_GEN2) - printf("SATA revision 2.x\n"); + printf(" SATA 2.x\n"); else if (parm->satacapabilities & ATA_SATA_GEN1) - printf("SATA revision 1.x\n"); + printf(" SATA 1.x\n"); else - printf("Unknown SATA revision\n"); + printf(" SATA x.x\n"); } else - printf("ATA/ATAPI revision %d\n", ata_version(parm->version_major)); + printf("\n"); printf("device model %.40s\n", parm->model); printf("serial number %.20s\n", parm->serial); printf("firmware revision %.8s\n", parm->revision); @@ -1038,22 +1040,74 @@ atacapprint(struct ata_params *parm) (parm->support.command2 & ATA_SUPPORT_CFA)) printf("CFA supported\n"); - printf("lba%ssupported ", + printf("LBA%ssupported ", parm->capabilities1 & ATA_SUPPORT_LBA ? " " : " not "); if (lbasize) printf("%d sectors\n", lbasize); else printf("\n"); - printf("lba48%ssupported ", + printf("LBA48%ssupported ", parm->support.command2 & ATA_SUPPORT_ADDRESS48 ? " " : " not "); if (lbasize48) printf("%ju sectors\n", (uintmax_t)lbasize48); else printf("\n"); - printf("dma%ssupported\n", + printf("PIO supported PIO"); + if (parm->atavalid & ATA_FLAG_64_70) { + if (parm->apiomodes & 0x02) + printf("4"); + else if (parm->apiomodes & 0x01) + printf("3"); + } else if (parm->mwdmamodes & 0x04) + printf("4"); + else if (parm->mwdmamodes & 0x02) + printf("3"); + else if (parm->mwdmamodes & 0x01) + printf("2"); + else if ((parm->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x200) + printf("2"); + else if ((parm->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x100) + printf("1"); + else + printf("0"); + printf("\n"); + + printf("DMA%ssupported ", parm->capabilities1 & ATA_SUPPORT_DMA ? " " : " not "); + if (parm->capabilities1 & ATA_SUPPORT_DMA) { + if (parm->mwdmamodes & 0xff) { + printf("WDMA"); + if (parm->mwdmamodes & 0x04) + printf("2"); + else if (parm->mwdmamodes & 0x02) + printf("1"); + else if (parm->mwdmamodes & 0x01) + printf("0"); + printf(" "); + } + if ((parm->atavalid & ATA_FLAG_88) && + (parm->udmamodes & 0xff)) { + printf("UDMA"); + if (parm->udmamodes & 0x40) + printf("6"); + else if (parm->udmamodes & 0x20) + printf("5"); + else if (parm->udmamodes & 0x10) + printf("4"); + else if (parm->udmamodes & 0x08) + printf("3"); + else if (parm->udmamodes & 0x04) + printf("2"); + else if (parm->udmamodes & 0x02) + printf("1"); + else if (parm->udmamodes & 0x01) + printf("0"); + printf(" "); + } + } + printf("\n"); printf("overlap%ssupported\n", parm->capabilities1 & ATA_SUPPORT_OVERLAP ? " " : " not "); @@ -1070,10 +1124,10 @@ atacapprint(struct ata_params *parm) parm->enabled.command1 & ATA_SUPPORT_LOOKAHEAD ? "yes" : "no"); if (parm->satacapabilities && parm->satacapabilities != 0xffff) { - printf("Native Command Queuing (NCQ) %s %s" + printf("Native Command Queuing (NCQ) %s " " %d/0x%02X\n", parm->satacapabilities & ATA_SUPPORT_NCQ ? - "yes" : "no", " -", + "yes" : "no", (parm->satacapabilities & ATA_SUPPORT_NCQ) ? ATA_QUEUE_LEN(parm->queue) : 0, (parm->satacapabilities & ATA_SUPPORT_NCQ) ? @@ -1121,9 +1175,14 @@ ataidentify(struct cam_device *device, i { union ccb *ccb; struct ata_params *ident_buf; + struct ccb_getdev cgd; u_int i, error = 0; int16_t *ptr; - + + if (get_cgd(device, &cgd) != 0) { + warnx("couldn't get CGD"); + return(1); + } ccb = cam_getccb(device); if (ccb == NULL) { @@ -1152,10 +1211,10 @@ ataidentify(struct cam_device *device, i /*data_ptr*/(u_int8_t *)ptr, /*dxfer_len*/sizeof(struct ata_params), timeout ? timeout : 30 * 1000); -// if (periph->path->device->protocol == PROTO_ATA) - ata_36bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0); -// else -// ata_36bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0); + if (cgd.protocol == PROTO_ATA) + ata_28bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0); + else + ata_28bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0); /* Disable freezing the device queue */ ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; @@ -2588,46 +2647,71 @@ get_cpi(struct cam_device *device, struc int retval = 0; ccb = cam_getccb(device); - if (ccb == NULL) { warnx("get_cpi: couldn't allocate CCB"); return(1); } - bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_pathinq) - sizeof(struct ccb_hdr)); - ccb->ccb_h.func_code = XPT_PATH_INQ; - if (cam_send_ccb(device, ccb) < 0) { warn("get_cpi: error sending Path Inquiry CCB"); - if (arglist & CAM_ARG_VERBOSE) cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); - retval = 1; - goto get_cpi_bailout; } - if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - if (arglist & CAM_ARG_VERBOSE) cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); - retval = 1; - goto get_cpi_bailout; } - bcopy(&ccb->cpi, cpi, sizeof(struct ccb_pathinq)); get_cpi_bailout: - cam_freeccb(ccb); + return(retval); +} +/* + * Get a get device CCB for the specified device. + */ +static int +get_cgd(struct cam_device *device, struct ccb_getdev *cgd) +{ + union ccb *ccb; + int retval = 0; + + ccb = cam_getccb(device); + if (ccb == NULL) { + warnx("get_cgd: couldn't allocate CCB"); + return(1); + } + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_pathinq) - sizeof(struct ccb_hdr)); + ccb->ccb_h.func_code = XPT_GDEV_TYPE; + if (cam_send_ccb(device, ccb) < 0) { + warn("get_cgd: error sending Path Inquiry CCB"); + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + retval = 1; + goto get_cgd_bailout; + } + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + if (arglist & CAM_ARG_VERBOSE) + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + retval = 1; + goto get_cgd_bailout; + } + bcopy(&ccb->cgd, cgd, sizeof(struct ccb_getdev)); + +get_cgd_bailout: + cam_freeccb(ccb); return(retval); } @@ -2673,6 +2757,9 @@ cpi_print(struct ccb_pathinq *cpi) case PI_SOFT_RST: str = "soft reset alternative"; break; + case PI_SATAPM: + str = "SATA Port Multiplier"; + break; default: str = "unknown PI bit set"; break; @@ -2702,6 +2789,12 @@ cpi_print(struct ccb_pathinq *cpi) str = "user has disabled initial BUS RESET or" " controller is in target/mixed mode"; break; + case PIM_NO_6_BYTE: + str = "do not send 6-byte commands"; + break; + case PIM_SEQSCAN: + str = "scan bus sequentially"; + break; default: str = "unknown PIM bit set"; break; Modified: stable/8/sys/cam/ata/ata_all.c ============================================================================== --- stable/8/sys/cam/ata/ata_all.c Tue Sep 1 11:44:30 2009 (r196731) +++ stable/8/sys/cam/ata/ata_all.c Tue Sep 1 12:04:43 2009 (r196732) @@ -91,7 +91,7 @@ ata_print_ident(struct ata_params *ident } void -ata_36bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, +ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, uint32_t lba, uint8_t sector_count) { bzero(&ataio->cmd, sizeof(ataio->cmd)); Modified: stable/8/sys/cam/ata/ata_all.h ============================================================================== --- stable/8/sys/cam/ata/ata_all.h Tue Sep 1 11:44:30 2009 (r196731) +++ stable/8/sys/cam/ata/ata_all.h Tue Sep 1 12:04:43 2009 (r196732) @@ -83,7 +83,7 @@ struct ata_res { int ata_version(int ver); void ata_print_ident(struct ata_params *ident_data); -void ata_36bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, +void ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features, uint32_t lba, uint8_t sector_count); void ata_48bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint16_t features, uint64_t lba, uint16_t sector_count); Modified: stable/8/sys/cam/ata/ata_da.c ============================================================================== --- stable/8/sys/cam/ata/ata_da.c Tue Sep 1 11:44:30 2009 (r196731) +++ stable/8/sys/cam/ata/ata_da.c Tue Sep 1 12:04:43 2009 (r196732) @@ -287,7 +287,7 @@ adaclose(struct disk *dp) if (softc->flags & ADA_FLAG_CAN_48BIT) ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE48, 0, 0, 0); else - ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0); + ata_28bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0); cam_periph_runccb(ccb, /*error_routine*/NULL, /*cam_flags*/0, /*sense_flags*/SF_RETRY_UA, softc->disk->d_devstat); @@ -411,7 +411,7 @@ adadump(void *arg, void *virtual, vm_off ata_48bit_cmd(&ccb.ataio, ATA_WRITE_DMA48, 0, lba, count); } else { - ata_36bit_cmd(&ccb.ataio, ATA_WRITE_DMA, + ata_28bit_cmd(&ccb.ataio, ATA_WRITE_DMA, 0, lba, count); } xpt_polled_action(&ccb); @@ -441,7 +441,7 @@ adadump(void *arg, void *virtual, vm_off if (softc->flags & ADA_FLAG_CAN_48BIT) ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0); else - ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0); + ata_28bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0); xpt_polled_action(&ccb); if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) @@ -856,10 +856,10 @@ adastart(struct cam_periph *periph, unio } } else { if (bp->bio_cmd == BIO_READ) { - ata_36bit_cmd(ataio, ATA_READ_DMA, + ata_28bit_cmd(ataio, ATA_READ_DMA, 0, lba, count); } else { - ata_36bit_cmd(ataio, ATA_WRITE_DMA, + ata_28bit_cmd(ataio, ATA_WRITE_DMA, 0, lba, count); } } @@ -878,7 +878,7 @@ adastart(struct cam_periph *periph, unio if (softc->flags & ADA_FLAG_CAN_48BIT) ata_48bit_cmd(ataio, ATA_FLUSHCACHE48, 0, 0, 0); else - ata_48bit_cmd(ataio, ATA_FLUSHCACHE, 0, 0, 0); + ata_28bit_cmd(ataio, ATA_FLUSHCACHE, 0, 0, 0); break; } start_ccb->ccb_h.ccb_state = ADA_CCB_BUFFER_IO; @@ -1126,7 +1126,7 @@ adashutdown(void * arg, int howto) if (softc->flags & ADA_FLAG_CAN_48BIT) ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0); else - ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0); + ata_28bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0); xpt_polled_action(&ccb); if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) Modified: stable/8/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/8/sys/cam/ata/ata_xpt.c Tue Sep 1 11:44:30 2009 (r196731) +++ stable/8/sys/cam/ata/ata_xpt.c Tue Sep 1 12:04:43 2009 (r196732) @@ -357,9 +357,9 @@ probestart(struct cam_periph *periph, un /*dxfer_len*/sizeof(struct ata_params), 30 * 1000); if (periph->path->device->protocol == PROTO_ATA) - ata_36bit_cmd(ataio, ATA_ATA_IDENTIFY, 0, 0, 0); + ata_28bit_cmd(ataio, ATA_ATA_IDENTIFY, 0, 0, 0); else - ata_36bit_cmd(ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0); + ata_28bit_cmd(ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0); break; } case PROBE_SETMODE: @@ -375,7 +375,7 @@ probestart(struct cam_periph *periph, un /*data_ptr*/NULL, /*dxfer_len*/0, 30 * 1000); - ata_36bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0, + ata_28bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0, ata_max_mode(ident_buf, ATA_UDMA6, ATA_UDMA6)); break; } From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 15:50:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92B781065672; Tue, 1 Sep 2009 15:50:07 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F84E8FC17; Tue, 1 Sep 2009 15:50:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81Fo75f065564; Tue, 1 Sep 2009 15:50:07 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81Fo7lp065562; Tue, 1 Sep 2009 15:50:07 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909011550.n81Fo7lp065562@svn.freebsd.org> From: John Baldwin Date: Tue, 1 Sep 2009 15:50:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196735 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 15:50:07 -0000 Author: jhb Date: Tue Sep 1 15:50:07 2009 New Revision: 196735 URL: http://svn.freebsd.org/changeset/base/196735 Log: MFC 196637: Mark the fake pages constructed by the OBJT_SG pager valid. This was accidentally lost at one point during the PAT development. Without this fix vm_pager_get_pages() was zeroing each of the pages. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/vm/sg_pager.c Modified: stable/8/sys/vm/sg_pager.c ============================================================================== --- stable/8/sys/vm/sg_pager.c Tue Sep 1 12:17:47 2009 (r196734) +++ stable/8/sys/vm/sg_pager.c Tue Sep 1 15:50:07 2009 (r196735) @@ -204,6 +204,7 @@ sg_pager_getpages(vm_object_t object, vm vm_page_unlock_queues(); vm_page_insert(page, object, offset); m[reqpage] = page; + page->valid = VM_PAGE_BITS_ALL; return (VM_PAGER_OK); } From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 16:41:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E23D106568B; Tue, 1 Sep 2009 16:41:29 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1A9958FC0A; Tue, 1 Sep 2009 16:41:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81GfS25066714; Tue, 1 Sep 2009 16:41:28 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81GfSR5066711; Tue, 1 Sep 2009 16:41:28 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200909011641.n81GfSR5066711@svn.freebsd.org> From: Robert Noland Date: Tue, 1 Sep 2009 16:41:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196737 - in stable/8/sys: . amd64/amd64 amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci i386/i386 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 16:41:29 -0000 Author: rnoland Date: Tue Sep 1 16:41:28 2009 New Revision: 196737 URL: http://svn.freebsd.org/changeset/base/196737 Log: MFC 196643 Swap the start/end virtual addresses in pmap_invalidate_cache_range(). This fixes the functionality on non SelfSnoop hardware. Found by: rnoland Submitted by: alc Reviewed by: kib Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/amd64/pmap.c stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/i386/i386/pmap.c Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Tue Sep 1 15:51:36 2009 (r196736) +++ stable/8/sys/amd64/amd64/pmap.c Tue Sep 1 16:41:28 2009 (r196737) @@ -943,8 +943,8 @@ pmap_invalidate_cache_range(vm_offset_t * coherence domain. */ mfence(); - for (; eva < sva; eva += cpu_clflush_line_size) - clflush(eva); + for (; sva < eva; sva += cpu_clflush_line_size) + clflush(sva); mfence(); } else { Modified: stable/8/sys/i386/i386/pmap.c ============================================================================== --- stable/8/sys/i386/i386/pmap.c Tue Sep 1 15:51:36 2009 (r196736) +++ stable/8/sys/i386/i386/pmap.c Tue Sep 1 16:41:28 2009 (r196737) @@ -967,8 +967,8 @@ pmap_invalidate_cache_range(vm_offset_t * coherence domain. */ mfence(); - for (; eva < sva; eva += cpu_clflush_line_size) - clflush(eva); + for (; sva < eva; sva += cpu_clflush_line_size) + clflush(sva); mfence(); } else { From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 16:56:20 2009 Return-Path: Delivered-To: svn-src-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B4961065693 for ; Tue, 1 Sep 2009 16:56:20 +0000 (UTC) (envelope-from njm@njm.me.uk) Received: from smtp004.apm-internet.net (smtp004.apm-internet.net [85.119.248.54]) by mx1.freebsd.org (Postfix) with SMTP id E20118FC17 for ; Tue, 1 Sep 2009 16:56:19 +0000 (UTC) Received: (qmail 99074 invoked from network); 1 Sep 2009 16:29:39 -0000 Received: from unknown (HELO titania.njm.me.uk) (86.138.89.107) by smtp004.apm-internet.net with SMTP; 1 Sep 2009 16:29:39 -0000 Received: from titania.njm.me.uk (localhost [127.0.0.1]) by titania.njm.me.uk (8.14.3/8.14.3) with ESMTP id n81GTdid002402; Tue, 1 Sep 2009 17:29:39 +0100 (BST) (envelope-from njm@njm.me.uk) Received: (from njm@localhost) by titania.njm.me.uk (8.14.3/8.14.3/Submit) id n81GTdVU002401; Tue, 1 Sep 2009 17:29:39 +0100 (BST) (envelope-from njm@njm.me.uk) Date: Tue, 1 Sep 2009 17:29:39 +0100 From: "N.J. Mann" To: Edwin Groothuis Message-ID: <20090901162939.GA2371@titania.njm.me.uk> Mail-Followup-To: Edwin Groothuis , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org References: <200908310245.n7V2jliD013837@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200908310245.n7V2jliD013837@svn.freebsd.org> X-Operating-System: FreeBSD 7.2-STABLE User-Agent: mutt-NJM (2009-07-16) Cc: svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, svn-src-stable-7@FreeBSD.org Subject: Re: svn commit: r196684 - stable/7 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 16:56:20 -0000 In message <200908310245.n7V2jliD013837@svn.freebsd.org>, Edwin Groothuis (edwin@FreeBSD.org) wrote: > Author: edwin > Date: Mon Aug 31 02:45:47 2009 > New Revision: 196684 > URL: http://svn.freebsd.org/changeset/base/196684 > > Log: > MFC of r192625: > > Throw alert about the newly generated format of zic(8) and the > necessarity to run tzsetup(8). > > Modified: > stable/7/UPDATING (contents, props changed) > > Modified: stable/7/UPDATING > ============================================================================== > --- stable/7/UPDATING Mon Aug 31 02:22:18 2009 (r196683) > +++ stable/7/UPDATING Mon Aug 31 02:45:47 2009 (r196684) > @@ -8,6 +8,11 @@ Items affecting the ports and packages s > /usr/ports/UPDATING. Please read that file before running > portupgrade. > > +20090831: > + The newly imported zic(8) produces a new format in the > + output. Please run tzsetup(8) to install the newly created > + data to /etc/localtime. > + > 20090731: > The ABI of various structures related to the SYSV IPC API have > been changed. Bump __FreeBSD_version to 702105. I have just updated one of my machines that runs 7-STABLE and having done so I followed the above instructions. Having read the instructions I was expecting the new version of /etc/localtime to be different from the old one. However, the new one is identical to the old one. Is this to be expected? Cheers, Nick. -- From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 20:58:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2913B1065679; Tue, 1 Sep 2009 20:58:43 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 138558FC0C; Tue, 1 Sep 2009 20:58:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81KwfTk072170; Tue, 1 Sep 2009 20:58:41 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81KwfSk072165; Tue, 1 Sep 2009 20:58:41 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <200909012058.n81KwfSk072165@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 1 Sep 2009 20:58:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196741 - in stable/8: sys sys/amd64/include/xen sys/cddl/contrib/opensolaris sys/contrib/dev/acpica sys/contrib/pf sys/dev/xen/xenpci sys/fs/fifofs sys/kern tools/regression/poll X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 20:58:43 -0000 Author: jilles Date: Tue Sep 1 20:58:41 2009 New Revision: 196741 URL: http://svn.freebsd.org/changeset/base/196741 Log: MFC r196460 Fix the conformance of poll(2) for sockets after r195423 by returning POLLHUP instead of POLLIN for several cases. Now, the tools/regression/poll results for FreeBSD are closer to that of the Solaris and Linux. Also, improve the POSIX conformance by explicitely clearing POLLOUT when POLLHUP is reported in pollscan(), making the fix global. Submitted by: bde Reviewed by: rwatson MFC r196556 Fix poll() on half-closed sockets, while retaining POLLHUP for fifos. This reverts part of r196460, so that sockets only return POLLHUP if both directions are closed/error. Fifos get POLLHUP by closing the unused direction immediately after creating the sockets. The tools/regression/poll/*poll.c tests now pass except for two other things: - if POLLHUP is returned, POLLIN is always returned as well instead of only when there is data left in the buffer to be read - fifo old/new reader distinction does not work the way POSIX specs it Reviewed by: kib, bde MFC r196554 Add some tests for poll(2)/shutdown(2) interaction. Approved by: re (kensmith) Added: stable/8/tools/regression/poll/sockpoll.c - copied unchanged from r196554, head/tools/regression/poll/sockpoll.c Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/fs/fifofs/fifo_vnops.c stable/8/sys/kern/sys_generic.c stable/8/tools/regression/poll/ (props changed) stable/8/tools/regression/poll/Makefile Modified: stable/8/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- stable/8/sys/fs/fifofs/fifo_vnops.c Tue Sep 1 18:30:17 2009 (r196740) +++ stable/8/sys/fs/fifofs/fifo_vnops.c Tue Sep 1 20:58:41 2009 (r196741) @@ -193,6 +193,9 @@ fifo_open(ap) goto fail2; fip->fi_writesock = wso; error = soconnect2(wso, rso); + /* Close the direction we do not use, so we can get POLLHUP. */ + if (error == 0) + error = soshutdown(rso, SHUT_WR); if (error) { (void)soclose(wso); fail2: Modified: stable/8/sys/kern/sys_generic.c ============================================================================== --- stable/8/sys/kern/sys_generic.c Tue Sep 1 18:30:17 2009 (r196740) +++ stable/8/sys/kern/sys_generic.c Tue Sep 1 20:58:41 2009 (r196741) @@ -1228,6 +1228,13 @@ pollscan(td, fds, nfd) selfdalloc(td, fds); fds->revents = fo_poll(fp, fds->events, td->td_ucred, td); + /* + * POSIX requires POLLOUT to be never + * set simultaneously with POLLHUP. + */ + if ((fds->revents & POLLHUP) != 0) + fds->revents &= ~POLLOUT; + if (fds->revents != 0) n++; } Modified: stable/8/tools/regression/poll/Makefile ============================================================================== --- stable/8/tools/regression/poll/Makefile Tue Sep 1 18:30:17 2009 (r196740) +++ stable/8/tools/regression/poll/Makefile Tue Sep 1 20:58:41 2009 (r196741) @@ -3,14 +3,15 @@ # Nothing yet works with gmake for the path to the sources. .PATH: .. -PROG= pipepoll pipeselect +PROG= pipepoll pipeselect sockpoll CFLAGS+= -Werror -Wall all: ${PROG} pipepoll: pipepoll.c pipeselect: pipeselect.c +sockpoll: sockpoll.c -pipepoll pipeselect: +pipepoll pipeselect sockpoll: ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $@.c test: all Copied: stable/8/tools/regression/poll/sockpoll.c (from r196554, head/tools/regression/poll/sockpoll.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/poll/sockpoll.c Tue Sep 1 20:58:41 2009 (r196741, copy of r196554, head/tools/regression/poll/sockpoll.c) @@ -0,0 +1,202 @@ +/* $FreeBSD$ */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +static const char * +decode_events(int events) +{ + char *ncresult; + const char *result; + + switch (events) { + case POLLIN: + result = "POLLIN"; + break; + case POLLOUT: + result = "POLLOUT"; + break; + case POLLIN | POLLOUT: + result = "POLLIN | POLLOUT"; + break; + case POLLHUP: + result = "POLLHUP"; + break; + case POLLIN | POLLHUP: + result = "POLLIN | POLLHUP"; + break; + case POLLOUT | POLLHUP: + result = "POLLOUT | POLLHUP"; + break; + case POLLIN | POLLOUT | POLLHUP: + result = "POLLIN | POLLOUT | POLLHUP"; + break; + default: + asprintf(&ncresult, "%#x", events); + result = ncresult; + break; + } + return (result); +} + +static void +report(int num, const char *state, int expected, int got) +{ + if (expected == got) + printf("ok %-2d ", num); + else + printf("not ok %-2d", num); + printf(" state %s: expected %s; got %s\n", + state, decode_events(expected), decode_events(got)); + fflush(stdout); +} + +static int +set_nonblocking(int sck) +{ + int flags; + + flags = fcntl(sck, F_GETFL, 0); + flags |= O_NONBLOCK; + + if (fcntl(sck, F_SETFL, flags)) + return -1; + + return 0; +} + +static char largeblock[1048576]; /* should be more than AF_UNIX sockbuf size */ +static int fd[2]; +static struct pollfd pfd0; +static struct pollfd pfd1; + +void +setup(void) +{ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != 0) + err(1, "socketpair"); + if (set_nonblocking(fd[0]) == -1) + err(1, "fcntl"); + if (set_nonblocking(fd[1]) == -1) + err(1, "fcntl"); + pfd0.fd = fd[0]; + pfd0.events = POLLIN | POLLOUT; + pfd1.fd = fd[1]; + pfd1.events = POLLIN | POLLOUT; +} + +int +main(void) +{ + int num; + + num = 1; + printf("1..18\n"); + fflush(stdout); + + /* Large write with close */ + setup(); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "initial 0", POLLOUT, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "initial 1", POLLOUT, pfd1.revents); + if (write(fd[0], largeblock, sizeof(largeblock)) == -1) + err(1, "write"); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "after large write", 0, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after large write", POLLIN | POLLOUT, pfd1.revents); + close(fd[0]); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after close", POLLIN | POLLHUP, pfd1.revents); + if (read(fd[1], largeblock, sizeof(largeblock)) == -1) + err(1, "read"); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after reading input", POLLHUP, pfd1.revents); + close(fd[1]); + + /* With shutdown(SHUT_WR) */ + setup(); + if (shutdown(fd[0], SHUT_WR) == -1) + err(1, "shutdown"); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "after shutdown(SHUT_WR)", POLLOUT, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after shutdown(SHUT_WR)", POLLIN | POLLOUT, pfd1.revents); + switch (read(fd[1], largeblock, sizeof(largeblock))) { + case 0: + break; + case -1: + err(1, "read after other side shutdown"); + break; + default: + errx(1, "kernel made up data that was never written"); + } + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after reading EOF", POLLIN | POLLOUT, pfd1.revents); + if (write(fd[1], largeblock, sizeof(largeblock)) == -1) + err(1, "write"); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "after data from other side", POLLIN | POLLOUT, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "after writing", POLLIN, pfd1.revents); + if (shutdown(fd[1], SHUT_WR) == -1) + err(1, "shutdown second"); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "after second shutdown", POLLIN | POLLHUP, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "after second shutdown", POLLHUP, pfd1.revents); + close(fd[0]); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "after close", POLLHUP, pfd1.revents); + close(fd[1]); + + /* + * With shutdown(SHUT_RD) + * Note that shutdown(SHUT_WR) is passed to the peer, but + * shutdown(SHUT_RD) is not. + */ + setup(); + if (shutdown(fd[0], SHUT_RD) == -1) + err(1, "shutdown"); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "after shutdown(SHUT_RD)", POLLIN | POLLOUT, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after shutdown(SHUT_RD)", POLLOUT, pfd1.revents); + if (shutdown(fd[0], SHUT_WR) == -1) + err(1, "shutdown"); + if (poll(&pfd0, 1, 0) == -1) + err(1, "poll"); + report(num++, "after shutdown(SHUT_WR)", POLLHUP, pfd0.revents); + if (poll(&pfd1, 1, 0) == -1) + err(1, "poll"); + report(num++, "other side after shutdown(SHUT_WR)", POLLIN | POLLOUT, pfd1.revents); + close(fd[0]); + close(fd[1]); + + return (0); +} From owner-svn-src-stable@FreeBSD.ORG Tue Sep 1 21:31:14 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B0A4106566C; Tue, 1 Sep 2009 21:31:14 +0000 (UTC) (envelope-from marcus@freebsd.org) Received: from av-tac-rtp.cisco.com (hen.cisco.com [64.102.19.198]) by mx1.freebsd.org (Postfix) with ESMTP id BE3278FC16; Tue, 1 Sep 2009 21:31:13 +0000 (UTC) X-TACSUNS: Virus Scanned Received: from rooster.cisco.com (localhost.cisco.com [127.0.0.1]) by av-tac-rtp.cisco.com (8.13.8+Sun/8.13.8) with ESMTP id n81L7Hwk013186; Tue, 1 Sep 2009 17:07:17 -0400 (EDT) Received: from dhcp-64-102-220-149.cisco.com (dhcp-64-102-220-149.cisco.com [64.102.220.149]) by rooster.cisco.com (8.13.8+Sun/8.13.8) with ESMTP id n81L7HYT003913; Tue, 1 Sep 2009 17:07:17 -0400 (EDT) Message-ID: <4A9D8D05.60206@freebsd.org> Date: Tue, 01 Sep 2009 17:07:17 -0400 From: Joe Marcus Clarke Organization: FreeBSD, Inc. User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Jilles Tjoelker References: <200909012058.n81KwfSk072165@svn.freebsd.org> In-Reply-To: <200909012058.n81KwfSk072165@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196741 - in stable/8: sys sys/amd64/include/xen sys/cddl/contrib/opensolaris sys/contrib/dev/acpica sys/contrib/pf sys/dev/xen/xenpci sys/fs/fifofs sys/kern tools/regression/poll X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 21:31:14 -0000 Jilles Tjoelker wrote: > Author: jilles > Date: Tue Sep 1 20:58:41 2009 > New Revision: 196741 > URL: http://svn.freebsd.org/changeset/base/196741 > > Log: > MFC r196460 > > Fix the conformance of poll(2) for sockets after r195423 by > returning POLLHUP instead of POLLIN for several cases. Now, the > tools/regression/poll results for FreeBSD are closer to that of the > Solaris and Linux. This is a huge change in terms of porting. I can't tell you how many times I've had to fix Linux (GNOME) apps to work on FreeBSD in this regard. Is this fix going to be ported to 7.X? Can we get a __FreeBSD_version bump? Joe -- Joe Marcus Clarke FreeBSD GNOME Team :: gnome@FreeBSD.org FreeNode / #freebsd-gnome http://www.FreeBSD.org/gnome From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 02:12:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AE6B11065670; Wed, 2 Sep 2009 02:12:07 +0000 (UTC) (envelope-from alfred@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 99DE88FC13; Wed, 2 Sep 2009 02:12:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n822C7L4078389; Wed, 2 Sep 2009 02:12:07 GMT (envelope-from alfred@svn.freebsd.org) Received: (from alfred@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n822C7Il078379; Wed, 2 Sep 2009 02:12:07 GMT (envelope-from alfred@svn.freebsd.org) Message-Id: <200909020212.n822C7Il078379@svn.freebsd.org> From: Alfred Perlstein Date: Wed, 2 Sep 2009 02:12:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 02:12:07 -0000 Author: alfred Date: Wed Sep 2 02:12:07 2009 New Revision: 196746 URL: http://svn.freebsd.org/changeset/base/196746 Log: MFC: r196489,196498 Critical USB bugfixes for 8.0 Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/usb/input/ukbd.c stable/8/sys/dev/usb/usb_dev.c stable/8/sys/dev/usb/usb_device.c stable/8/sys/dev/usb/usb_device.h stable/8/sys/dev/usb/usb_handle_request.c stable/8/sys/dev/usb/usb_hub.c stable/8/sys/dev/usb/usb_process.c stable/8/sys/dev/usb/usb_process.h stable/8/sys/dev/usb/usb_transfer.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/8/sys/dev/usb/input/ukbd.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/input/ukbd.c Wed Sep 2 02:12:07 2009 (r196746) @@ -96,10 +96,14 @@ __FBSDID("$FreeBSD$"); #if USB_DEBUG static int ukbd_debug = 0; +static int ukbd_no_leds = 0; SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB ukbd"); SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW, &ukbd_debug, 0, "Debug level"); +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW, + &ukbd_no_leds, 0, "Disables setting of keyboard leds"); + #endif #define UPROTO_BOOT_KEYBOARD 1 @@ -165,6 +169,7 @@ struct ukbd_softc { #define UKBD_FLAG_APPLE_EJECT 0x0040 #define UKBD_FLAG_APPLE_FN 0x0080 #define UKBD_FLAG_APPLE_SWAP 0x0100 +#define UKBD_FLAG_TIMER_RUNNING 0x0200 int32_t sc_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ int32_t sc_state; /* shift/lock key state */ @@ -279,6 +284,25 @@ static device_attach_t ukbd_attach; static device_detach_t ukbd_detach; static device_resume_t ukbd_resume; +static uint8_t +ukbd_any_key_pressed(struct ukbd_softc *sc) +{ + uint8_t i; + uint8_t j; + + for (j = i = 0; i < UKBD_NKEYCODE; i++) + j |= sc->sc_odata.keycode[i]; + + return (j ? 1 : 0); +} + +static void +ukbd_start_timer(struct ukbd_softc *sc) +{ + sc->sc_flags |= UKBD_FLAG_TIMER_RUNNING; + usb_callout_reset(&sc->sc_callout, hz / 40, &ukbd_timeout, sc); +} + static void ukbd_put_key(struct ukbd_softc *sc, uint32_t key) { @@ -308,11 +332,15 @@ ukbd_do_poll(struct ukbd_softc *sc, uint usbd_transfer_poll(sc->sc_xfer, UKBD_N_TRANSFER); - DELAY(1000); /* delay 1 ms */ + /* Delay-optimised support for repetition of keys */ - sc->sc_time_ms++; + if (ukbd_any_key_pressed(sc)) { + /* a key is pressed - need timekeeping */ + DELAY(1000); - /* support repetition of keys: */ + /* 1 millisecond has passed */ + sc->sc_time_ms += 1; + } ukbd_interrupt(sc); @@ -470,7 +498,11 @@ ukbd_timeout(void *arg) } ukbd_interrupt(sc); - usb_callout_reset(&sc->sc_callout, hz / 40, &ukbd_timeout, sc); + if (ukbd_any_key_pressed(sc)) { + ukbd_start_timer(sc); + } else { + sc->sc_flags &= ~UKBD_FLAG_TIMER_RUNNING; + } } static uint8_t @@ -582,6 +614,12 @@ ukbd_intr_callback(struct usb_xfer *xfer } ukbd_interrupt(sc); + + if (!(sc->sc_flags & UKBD_FLAG_TIMER_RUNNING)) { + if (ukbd_any_key_pressed(sc)) { + ukbd_start_timer(sc); + } + } } case USB_ST_SETUP: tr_setup: @@ -613,6 +651,11 @@ ukbd_set_leds_callback(struct usb_xfer * uint8_t buf[2]; struct ukbd_softc *sc = usbd_xfer_softc(xfer); +#if USB_DEBUG + if (ukbd_no_leds) + return; +#endif + switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: case USB_ST_SETUP: @@ -647,11 +690,11 @@ ukbd_set_leds_callback(struct usb_xfer * usbd_xfer_set_frames(xfer, 2); usbd_transfer_submit(xfer); } - return; + break; default: /* Error */ DPRINTFN(0, "error=%s\n", usbd_errstr(error)); - return; + break; } } @@ -745,8 +788,6 @@ ukbd_attach(device_t dev) uint16_t n; uint16_t hid_len; - mtx_assert(&Giant, MA_OWNED); - kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0); kbd->kb_data = (void *)sc; @@ -831,7 +872,7 @@ ukbd_attach(device_t dev) } /* ignore if SETIDLE fails, hence it is not crucial */ - err = usbd_req_set_idle(sc->sc_udev, &Giant, sc->sc_iface_index, 0, 0); + err = usbd_req_set_idle(sc->sc_udev, NULL, sc->sc_iface_index, 0, 0); ukbd_ioctl(kbd, KDSETLED, (caddr_t)&sc->sc_state); @@ -862,9 +903,6 @@ ukbd_attach(device_t dev) usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT]); - /* start the timer */ - - ukbd_timeout(sc); mtx_unlock(&Giant); return (0); /* success */ @@ -879,8 +917,6 @@ ukbd_detach(device_t dev) struct ukbd_softc *sc = device_get_softc(dev); int error; - mtx_assert(&Giant, MA_OWNED); - DPRINTF("\n"); if (sc->sc_flags & UKBD_FLAG_POLLING) { @@ -927,8 +963,6 @@ ukbd_resume(device_t dev) { struct ukbd_softc *sc = device_get_softc(dev); - mtx_assert(&Giant, MA_OWNED); - ukbd_clear_state(&sc->sc_kbd); return (0); @@ -945,7 +979,6 @@ ukbd_configure(int flags) static int ukbd__probe(int unit, void *arg, int flags) { - mtx_assert(&Giant, MA_OWNED); return (ENXIO); } @@ -953,7 +986,6 @@ ukbd__probe(int unit, void *arg, int fla static int ukbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) { - mtx_assert(&Giant, MA_OWNED); return (ENXIO); } @@ -961,7 +993,6 @@ ukbd_init(int unit, keyboard_t **kbdp, v static int ukbd_test_if(keyboard_t *kbd) { - mtx_assert(&Giant, MA_OWNED); return (0); } @@ -969,7 +1000,6 @@ ukbd_test_if(keyboard_t *kbd) static int ukbd_term(keyboard_t *kbd) { - mtx_assert(&Giant, MA_OWNED); return (ENXIO); } @@ -977,7 +1007,6 @@ ukbd_term(keyboard_t *kbd) static int ukbd_intr(keyboard_t *kbd, void *arg) { - mtx_assert(&Giant, MA_OWNED); return (0); } @@ -985,7 +1014,6 @@ ukbd_intr(keyboard_t *kbd, void *arg) static int ukbd_lock(keyboard_t *kbd, int lock) { - mtx_assert(&Giant, MA_OWNED); return (1); } @@ -1004,7 +1032,6 @@ ukbd_enable(keyboard_t *kbd) mtx_unlock(&Giant); return (retval); } - mtx_assert(&Giant, MA_OWNED); KBD_ACTIVATE(kbd); return (0); } @@ -1021,7 +1048,6 @@ ukbd_disable(keyboard_t *kbd) mtx_unlock(&Giant); return (retval); } - mtx_assert(&Giant, MA_OWNED); KBD_DEACTIVATE(kbd); return (0); } @@ -1050,7 +1076,6 @@ ukbd_check(keyboard_t *kbd) if (!mtx_owned(&Giant)) return (0); } - mtx_assert(&Giant, MA_OWNED); #ifdef UKBD_EMULATE_ATSCANCODE if (sc->sc_buffered_char[0]) { @@ -1086,7 +1111,6 @@ ukbd_check_char(keyboard_t *kbd) if (!mtx_owned(&Giant)) return (0); } - mtx_assert(&Giant, MA_OWNED); if ((sc->sc_composed_char > 0) && (!(sc->sc_flags & UKBD_FLAG_COMPOSE))) { @@ -1125,7 +1149,6 @@ ukbd_read(keyboard_t *kbd, int wait) if (!mtx_owned(&Giant)) return (-1); } - mtx_assert(&Giant, MA_OWNED); #ifdef UKBD_EMULATE_ATSCANCODE if (sc->sc_buffered_char[0]) { @@ -1190,7 +1213,6 @@ ukbd_read_char(keyboard_t *kbd, int wait if (!mtx_owned(&Giant)) return (NOKEY); } - mtx_assert(&Giant, MA_OWNED); next_code: @@ -1393,7 +1415,6 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, */ return (EINVAL); } - mtx_assert(&Giant, MA_OWNED); switch (cmd) { case KDGKBMODE: /* get keyboard mode */ @@ -1527,7 +1548,6 @@ ukbd_clear_state(keyboard_t *kbd) if (!mtx_owned(&Giant)) { return; /* XXX */ } - mtx_assert(&Giant, MA_OWNED); sc->sc_flags &= ~(UKBD_FLAG_COMPOSE | UKBD_FLAG_POLLING); sc->sc_state &= LOCK_MASK; /* preserve locking key state */ @@ -1547,7 +1567,6 @@ ukbd_clear_state(keyboard_t *kbd) static int ukbd_get_state(keyboard_t *kbd, void *buf, size_t len) { - mtx_assert(&Giant, MA_OWNED); return (len == 0) ? 1 : -1; } @@ -1555,7 +1574,6 @@ ukbd_get_state(keyboard_t *kbd, void *bu static int ukbd_set_state(keyboard_t *kbd, void *buf, size_t len) { - mtx_assert(&Giant, MA_OWNED); return (EINVAL); } @@ -1572,7 +1590,6 @@ ukbd_poll(keyboard_t *kbd, int on) mtx_unlock(&Giant); return (retval); } - mtx_assert(&Giant, MA_OWNED); if (on) { sc->sc_flags |= UKBD_FLAG_POLLING; Modified: stable/8/sys/dev/usb/usb_dev.c ============================================================================== --- stable/8/sys/dev/usb/usb_dev.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_dev.c Wed Sep 2 02:12:07 2009 (r196746) @@ -217,7 +217,7 @@ usb_ref_device(struct usb_cdev_privdata * We need to grab the sx-lock before grabbing the * FIFO refs to avoid deadlock at detach! */ - sx_xlock(cpd->udev->default_sx + 1); + usbd_enum_lock(cpd->udev); mtx_lock(&usb_ref_lock); @@ -275,14 +275,12 @@ usb_ref_device(struct usb_cdev_privdata } mtx_unlock(&usb_ref_lock); - if (crd->is_uref) { - mtx_lock(&Giant); /* XXX */ - } return (0); error: if (crd->is_uref) { - sx_unlock(cpd->udev->default_sx + 1); + usbd_enum_unlock(cpd->udev); + if (--(cpd->udev->refcount) == 0) { cv_signal(cpd->udev->default_cv + 1); } @@ -334,10 +332,9 @@ usb_unref_device(struct usb_cdev_privdat DPRINTFN(2, "cpd=%p is_uref=%d\n", cpd, crd->is_uref); - if (crd->is_uref) { - mtx_unlock(&Giant); /* XXX */ - sx_unlock(cpd->udev->default_sx + 1); - } + if (crd->is_uref) + usbd_enum_unlock(cpd->udev); + mtx_lock(&usb_ref_lock); if (crd->is_read) { if (--(crd->rxfifo->refcount) == 0) { @@ -1042,9 +1039,9 @@ usb_ioctl(struct cdev *dev, u_long cmd, * reference if we need it! */ err = usb_ref_device(cpd, &refs, 0 /* no uref */ ); - if (err) { + if (err) return (ENXIO); - } + fflags = cpd->fflags; f = NULL; /* set default value */ Modified: stable/8/sys/dev/usb/usb_device.c ============================================================================== --- stable/8/sys/dev/usb/usb_device.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_device.c Wed Sep 2 02:12:07 2009 (r196746) @@ -402,11 +402,11 @@ usb_unconfigure(struct usb_device *udev, uint8_t do_unlock; /* automatic locking */ - if (sx_xlocked(udev->default_sx + 1)) { + if (usbd_enum_is_locked(udev)) { do_unlock = 0; } else { do_unlock = 1; - sx_xlock(udev->default_sx + 1); + usbd_enum_lock(udev); } /* detach all interface drivers */ @@ -442,9 +442,8 @@ usb_unconfigure(struct usb_device *udev, udev->curr_config_no = USB_UNCONFIG_NO; udev->curr_config_index = USB_UNCONFIG_INDEX; - if (do_unlock) { - sx_unlock(udev->default_sx + 1); - } + if (do_unlock) + usbd_enum_unlock(udev); } /*------------------------------------------------------------------------* @@ -472,11 +471,11 @@ usbd_set_config_index(struct usb_device DPRINTFN(6, "udev=%p index=%d\n", udev, index); /* automatic locking */ - if (sx_xlocked(udev->default_sx + 1)) { + if (usbd_enum_is_locked(udev)) { do_unlock = 0; } else { do_unlock = 1; - sx_xlock(udev->default_sx + 1); + usbd_enum_lock(udev); } usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV); @@ -585,9 +584,8 @@ done: if (err) { usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV); } - if (do_unlock) { - sx_unlock(udev->default_sx + 1); - } + if (do_unlock) + usbd_enum_unlock(udev); return (err); } @@ -823,11 +821,11 @@ usbd_set_alt_interface_index(struct usb_ uint8_t do_unlock; /* automatic locking */ - if (sx_xlocked(udev->default_sx + 1)) { + if (usbd_enum_is_locked(udev)) { do_unlock = 0; } else { do_unlock = 1; - sx_xlock(udev->default_sx + 1); + usbd_enum_lock(udev); } if (iface == NULL) { err = USB_ERR_INVAL; @@ -863,9 +861,9 @@ usbd_set_alt_interface_index(struct usb_ iface->idesc->bAlternateSetting); done: - if (do_unlock) { - sx_unlock(udev->default_sx + 1); - } + if (do_unlock) + usbd_enum_unlock(udev); + return (err); } @@ -1230,11 +1228,11 @@ usb_probe_and_attach(struct usb_device * return (USB_ERR_INVAL); } /* automatic locking */ - if (sx_xlocked(udev->default_sx + 1)) { + if (usbd_enum_is_locked(udev)) { do_unlock = 0; } else { do_unlock = 1; - sx_xlock(udev->default_sx + 1); + usbd_enum_lock(udev); } if (udev->curr_config_index == USB_UNCONFIG_INDEX) { @@ -1315,9 +1313,9 @@ usb_probe_and_attach(struct usb_device * } } done: - if (do_unlock) { - sx_unlock(udev->default_sx + 1); - } + if (do_unlock) + usbd_enum_unlock(udev); + return (0); } @@ -1779,7 +1777,8 @@ repeat_set_config: } } else if (usb_test_huawei_autoinst_p(udev, &uaa) == 0) { DPRINTFN(0, "Found Huawei auto-install disk!\n"); - err = USB_ERR_STALLED; /* fake an error */ + /* leave device unconfigured */ + usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_SUBDEV); } } else { err = 0; /* set success */ @@ -1902,15 +1901,18 @@ static void usb_cdev_free(struct usb_device *udev) { struct usb_fs_privdata* pd; + struct cdev* pcdev; DPRINTFN(2, "Freeing device nodes\n"); while ((pd = LIST_FIRST(&udev->pd_list)) != NULL) { KASSERT(pd->cdev->si_drv1 == pd, ("privdata corrupt")); - destroy_dev_sched_cb(pd->cdev, usb_cdev_cleanup, pd); + pcdev = pd->cdev; pd->cdev = NULL; LIST_REMOVE(pd, pd_next); + if (pcdev != NULL) + destroy_dev_sched_cb(pcdev, usb_cdev_cleanup, pd); } } @@ -2448,3 +2450,37 @@ usbd_device_attached(struct usb_device * { return (udev->state > USB_STATE_DETACHED); } + +/* The following function locks enumerating the given USB device. */ + +void +usbd_enum_lock(struct usb_device *udev) +{ + sx_xlock(udev->default_sx + 1); + /* + * NEWBUS LOCK NOTE: We should check if any parent SX locks + * are locked before locking Giant. Else the lock can be + * locked multiple times. + */ + mtx_lock(&Giant); +} + +/* The following function unlocks enumerating the given USB device. */ + +void +usbd_enum_unlock(struct usb_device *udev) +{ + mtx_unlock(&Giant); + sx_xunlock(udev->default_sx + 1); +} + +/* + * The following function checks the enumerating lock for the given + * USB device. + */ + +uint8_t +usbd_enum_is_locked(struct usb_device *udev) +{ + return (sx_xlocked(udev->default_sx + 1)); +} Modified: stable/8/sys/dev/usb/usb_device.h ============================================================================== --- stable/8/sys/dev/usb/usb_device.h Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_device.h Wed Sep 2 02:12:07 2009 (r196746) @@ -211,5 +211,8 @@ uint8_t usb_peer_can_wakeup(struct usb_d struct usb_endpoint *usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep); void usb_set_device_state(struct usb_device *udev, enum usb_dev_state state); +void usbd_enum_lock(struct usb_device *); +void usbd_enum_unlock(struct usb_device *); +uint8_t usbd_enum_is_locked(struct usb_device *); #endif /* _USB_DEVICE_H_ */ Modified: stable/8/sys/dev/usb/usb_handle_request.c ============================================================================== --- stable/8/sys/dev/usb/usb_handle_request.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_handle_request.c Wed Sep 2 02:12:07 2009 (r196746) @@ -152,8 +152,8 @@ usb_handle_set_config(struct usb_xfer *x * attach: */ USB_XFER_UNLOCK(xfer); - mtx_lock(&Giant); /* XXX */ - sx_xlock(udev->default_sx + 1); + + usbd_enum_lock(udev); if (conf_no == USB_UNCONFIG_NO) { conf_no = USB_UNCONFIG_INDEX; @@ -176,8 +176,7 @@ usb_handle_set_config(struct usb_xfer *x goto done; } done: - mtx_unlock(&Giant); /* XXX */ - sx_unlock(udev->default_sx + 1); + usbd_enum_unlock(udev); USB_XFER_LOCK(xfer); return (err); } @@ -190,19 +189,19 @@ usb_check_alt_setting(struct usb_device usb_error_t err = 0; /* automatic locking */ - if (sx_xlocked(udev->default_sx + 1)) { + if (usbd_enum_is_locked(udev)) { do_unlock = 0; } else { do_unlock = 1; - sx_xlock(udev->default_sx + 1); + usbd_enum_lock(udev); } if (alt_index >= usbd_get_no_alts(udev->cdesc, iface->idesc)) err = USB_ERR_INVAL; - if (do_unlock) { - sx_unlock(udev->default_sx + 1); - } + if (do_unlock) + usbd_enum_unlock(udev); + return (err); } @@ -236,8 +235,8 @@ usb_handle_iface_request(struct usb_xfer * attach: */ USB_XFER_UNLOCK(xfer); - mtx_lock(&Giant); /* XXX */ - sx_xlock(udev->default_sx + 1); + + usbd_enum_lock(udev); error = ENXIO; @@ -353,20 +352,17 @@ tr_repeat: goto tr_stalled; } tr_valid: - mtx_unlock(&Giant); - sx_unlock(udev->default_sx + 1); + usbd_enum_unlock(udev); USB_XFER_LOCK(xfer); return (0); tr_short: - mtx_unlock(&Giant); - sx_unlock(udev->default_sx + 1); + usbd_enum_unlock(udev); USB_XFER_LOCK(xfer); return (USB_ERR_SHORT_XFER); tr_stalled: - mtx_unlock(&Giant); - sx_unlock(udev->default_sx + 1); + usbd_enum_unlock(udev); USB_XFER_LOCK(xfer); return (USB_ERR_STALLED); } Modified: stable/8/sys/dev/usb/usb_hub.c ============================================================================== --- stable/8/sys/dev/usb/usb_hub.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_hub.c Wed Sep 2 02:12:07 2009 (r196746) @@ -96,6 +96,7 @@ struct uhub_current_state { struct uhub_softc { struct uhub_current_state sc_st;/* current state */ device_t sc_dev; /* base device */ + struct mtx sc_mtx; /* our mutex */ struct usb_device *sc_udev; /* USB device */ struct usb_xfer *sc_xfer[UHUB_N_TRANSFER]; /* interrupt xfer */ uint8_t sc_flags; @@ -428,7 +429,6 @@ repeat: mode = USB_MODE_HOST; /* need to create a new child */ - child = usb_alloc_device(sc->sc_dev, udev->bus, udev, udev->depth + 1, portno - 1, portno, speed, mode); if (child == NULL) { @@ -691,6 +691,8 @@ uhub_attach(device_t dev) sc->sc_udev = udev; sc->sc_dev = dev; + mtx_init(&sc->sc_mtx, "USB HUB mutex", NULL, MTX_DEF); + snprintf(sc->sc_name, sizeof(sc->sc_name), "%s", device_get_nameunit(dev)); @@ -774,7 +776,7 @@ uhub_attach(device_t dev) } else { /* normal HUB */ err = usbd_transfer_setup(udev, &iface_index, sc->sc_xfer, - uhub_config, UHUB_N_TRANSFER, sc, &Giant); + uhub_config, UHUB_N_TRANSFER, sc, &sc->sc_mtx); } if (err) { DPRINTFN(0, "cannot setup interrupt transfer, " @@ -850,9 +852,9 @@ uhub_attach(device_t dev) /* Start the interrupt endpoint, if any */ if (sc->sc_xfer[0] != NULL) { - USB_XFER_LOCK(sc->sc_xfer[0]); + mtx_lock(&sc->sc_mtx); usbd_transfer_start(sc->sc_xfer[0]); - USB_XFER_UNLOCK(sc->sc_xfer[0]); + mtx_unlock(&sc->sc_mtx); } /* Enable automatic power save on all USB HUBs */ @@ -868,6 +870,9 @@ error: free(udev->hub, M_USBDEV); udev->hub = NULL; } + + mtx_destroy(&sc->sc_mtx); + return (ENXIO); } @@ -908,6 +913,9 @@ uhub_detach(device_t dev) free(hub, M_USBDEV); sc->sc_udev->hub = NULL; + + mtx_destroy(&sc->sc_mtx); + return (0); } @@ -1775,10 +1783,13 @@ usb_dev_resume_peer(struct usb_device *u /* always update hardware power! */ (bus->methods->set_hw_power) (bus); } - sx_xlock(udev->default_sx + 1); + + usbd_enum_lock(udev); + /* notify all sub-devices about resume */ err = usb_suspend_resume(udev, 0); - sx_unlock(udev->default_sx + 1); + + usbd_enum_unlock(udev); /* check if peer has wakeup capability */ if (usb_peer_can_wakeup(udev)) { @@ -1844,10 +1855,12 @@ repeat: } } - sx_xlock(udev->default_sx + 1); + usbd_enum_lock(udev); + /* notify all sub-devices about suspend */ err = usb_suspend_resume(udev, 1); - sx_unlock(udev->default_sx + 1); + + usbd_enum_unlock(udev); if (usb_peer_can_wakeup(udev)) { /* allow device to do remote wakeup */ Modified: stable/8/sys/dev/usb/usb_process.c ============================================================================== --- stable/8/sys/dev/usb/usb_process.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_process.c Wed Sep 2 02:12:07 2009 (r196746) @@ -457,3 +457,29 @@ usb_proc_drain(struct usb_process *up) } mtx_unlock(up->up_mtx); } + +/*------------------------------------------------------------------------* + * usb_proc_rewakeup + * + * This function is called to re-wakeup the the given USB + * process. This usually happens after that the USB system has been in + * polling mode, like during a panic. This function must be called + * having "up->up_mtx" locked. + *------------------------------------------------------------------------*/ +void +usb_proc_rewakeup(struct usb_process *up) +{ + /* check if not initialised */ + if (up->up_mtx == NULL) + return; + /* check if gone */ + if (up->up_gone) + return; + + mtx_assert(up->up_mtx, MA_OWNED); + + if (up->up_msleep == 0) { + /* re-wakeup */ + cv_signal(&up->up_cv); + } +} Modified: stable/8/sys/dev/usb/usb_process.h ============================================================================== --- stable/8/sys/dev/usb/usb_process.h Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_process.h Wed Sep 2 02:12:07 2009 (r196746) @@ -75,5 +75,6 @@ void usb_proc_drain(struct usb_process * void usb_proc_mwait(struct usb_process *up, void *pm0, void *pm1); void usb_proc_free(struct usb_process *up); void *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1); +void usb_proc_rewakeup(struct usb_process *up); #endif /* _USB_PROCESS_H_ */ Modified: stable/8/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/8/sys/dev/usb/usb_transfer.c Wed Sep 2 00:39:59 2009 (r196745) +++ stable/8/sys/dev/usb/usb_transfer.c Wed Sep 2 02:12:07 2009 (r196746) @@ -2907,13 +2907,9 @@ usbd_transfer_poll(struct usb_xfer **ppx } /* Make sure cv_signal() and cv_broadcast() is not called */ - udev->bus->control_xfer_proc.up_dsleep = 0; udev->bus->control_xfer_proc.up_msleep = 0; - udev->bus->explore_proc.up_dsleep = 0; udev->bus->explore_proc.up_msleep = 0; - udev->bus->giant_callback_proc.up_dsleep = 0; udev->bus->giant_callback_proc.up_msleep = 0; - udev->bus->non_giant_callback_proc.up_dsleep = 0; udev->bus->non_giant_callback_proc.up_msleep = 0; /* poll USB hardware */ From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 06:12:57 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90F23106566B; Wed, 2 Sep 2009 06:12:57 +0000 (UTC) (envelope-from remko@elvandar.org) Received: from websrv01.jr-hosting.nl (websrv01.jr-hosting.nl [78.47.69.233]) by mx1.freebsd.org (Postfix) with ESMTP id 0CC1C8FC0C; Wed, 2 Sep 2009 06:12:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=www.jr-hosting.nl) by websrv01.jr-hosting.nl with esmtpa (Exim 4.69 (FreeBSD)) (envelope-from ) id 1Mij5U-000DYG-30; Wed, 02 Sep 2009 08:12:56 +0200 Received: from 145.7.91.133 (SquirrelMail authenticated user remko) by www.jr-hosting.nl with HTTP; Wed, 2 Sep 2009 08:12:56 +0200 Message-ID: <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> In-Reply-To: <200909020212.n822C7Il078379@svn.freebsd.org> References: <200909020212.n822C7Il078379@svn.freebsd.org> Date: Wed, 2 Sep 2009 08:12:56 +0200 From: "Remko Lodder" To: "Alfred Perlstein" User-Agent: SquirrelMail/1.4.19 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: remko@elvandar.org List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 06:12:57 -0000 On Wed, September 2, 2009 4:12 am, Alfred Perlstein wrote: > Author: alfred > Date: Wed Sep 2 02:12:07 2009 > New Revision: 196746 > URL: http://svn.freebsd.org/changeset/base/196746 > > Log: > MFC: r196489,196498 > Critical USB bugfixes for 8.0 > Dear Alfred (and hps!), It would be awesome to see something more about this in the commit log. I needed to look up the specific revisions to see what changed. I always learned from Warner and people, that including the original commit message(s) saves a lot of time and makes it clear about what is being merged. Can you help and include a bit more information next time please? Thanks alot! -- /"\ Best regards, | remko@FreeBSD.org \ / Remko Lodder | remko@EFnet X http://www.evilcoder.org/ | / \ ASCII Ribbon Campaign | Against HTML Mail and News From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 10:05:10 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5319B106568B; Wed, 2 Sep 2009 10:05:10 +0000 (UTC) (envelope-from linimon@lonesome.com) Received: from mail.soaustin.net (lefty.soaustin.net [66.135.55.46]) by mx1.freebsd.org (Postfix) with ESMTP id 3174D8FC12; Wed, 2 Sep 2009 10:05:10 +0000 (UTC) Received: by mail.soaustin.net (Postfix, from userid 502) id 639FB8C092; Wed, 2 Sep 2009 04:45:08 -0500 (CDT) Date: Wed, 2 Sep 2009 04:45:08 -0500 From: Mark Linimon To: Alfred Perlstein Message-ID: <20090902094508.GA1964@lonesome.com> References: <200909020212.n822C7Il078379@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200909020212.n822C7Il078379@svn.freebsd.org> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 10:05:10 -0000 On Wed, Sep 02, 2009 at 02:12:07AM +0000, Alfred Perlstein wrote: > MFC: r196489,196498 > Critical USB bugfixes for 8.0 Will this change anything for ports? mcl From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 10:39:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4BF02106566B; Wed, 2 Sep 2009 10:39:47 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 37DC48FC17; Wed, 2 Sep 2009 10:39:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n82Adl1B093491; Wed, 2 Sep 2009 10:39:47 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n82AdlPn093485; Wed, 2 Sep 2009 10:39:47 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200909021039.n82AdlPn093485@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 2 Sep 2009 10:39:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196761 - in stable/8/sys: . amd64/amd64 amd64/include/xen cddl/contrib/opensolaris compat/ia32 contrib/dev/acpica contrib/pf dev/xen/xenpci i386/i386 kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 10:39:47 -0000 Author: bz Date: Wed Sep 2 10:39:46 2009 New Revision: 196761 URL: http://svn.freebsd.org/changeset/base/196761 Log: MFC r196653: Make sure FreeBSD binaries without .note.ABI-tag section work correctly and do not match a colliding Debian GNU/kFreeBSD brandinfo statements. For this mark the Debian GNU/kFreeBSD brandinfo that it must have an .note.ABI-tag section and ignore the old EI_OSABI brandinfo when comparing a possibly colliding set of options. Due to SYSINIT we add the brandinfo in a non-deterministic order, so native FreeBSD is not always first. We may want to consider to force native FreeBSD to come first as well. The only way a problem could currently be noticed is when running an i386 binary without the .note.ABI-tag on amd64 and the Debian GNU/kFreeBSD brandinfo was matched first, as the fallback to ld-elf32.so.1 does not exist in that case. Reported and tested by: ticso In collaboration with: kib MFC after: 3 days Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/amd64/elf_machdep.c stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/compat/ia32/ia32_sysvec.c stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/i386/i386/elf_machdep.c stable/8/sys/kern/imgact_elf.c stable/8/sys/sys/imgact_elf.h Modified: stable/8/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/elf_machdep.c Wed Sep 2 10:12:13 2009 (r196760) +++ stable/8/sys/amd64/amd64/elf_machdep.c Wed Sep 2 10:39:46 2009 (r196761) @@ -118,7 +118,7 @@ static Elf64_Brandinfo kfreebsd_brand_in .sysvec = &elf64_freebsd_sysvec, .interp_newpath = NULL, .brand_note = &elf64_kfreebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY }; SYSINIT(kelf64, SI_SUB_EXEC, SI_ORDER_ANY, Modified: stable/8/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- stable/8/sys/compat/ia32/ia32_sysvec.c Wed Sep 2 10:12:13 2009 (r196760) +++ stable/8/sys/compat/ia32/ia32_sysvec.c Wed Sep 2 10:39:46 2009 (r196761) @@ -180,7 +180,7 @@ static Elf32_Brandinfo kia32_brand_info .interp_path = "/lib/ld.so.1", .sysvec = &ia32_freebsd_sysvec, .brand_note = &elf32_kfreebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY }; SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY, Modified: stable/8/sys/i386/i386/elf_machdep.c ============================================================================== --- stable/8/sys/i386/i386/elf_machdep.c Wed Sep 2 10:12:13 2009 (r196760) +++ stable/8/sys/i386/i386/elf_machdep.c Wed Sep 2 10:39:46 2009 (r196761) @@ -117,7 +117,7 @@ static Elf32_Brandinfo kfreebsd_brand_in .sysvec = &elf32_freebsd_sysvec, .interp_newpath = NULL, .brand_note = &elf32_kfreebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE + .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE_MANDATORY }; SYSINIT(kelf32, SI_SUB_EXEC, SI_ORDER_ANY, Modified: stable/8/sys/kern/imgact_elf.c ============================================================================== --- stable/8/sys/kern/imgact_elf.c Wed Sep 2 10:12:13 2009 (r196760) +++ stable/8/sys/kern/imgact_elf.c Wed Sep 2 10:39:46 2009 (r196761) @@ -238,8 +238,10 @@ __elfN(get_brandinfo)(struct image_param /* Look for an ".note.ABI-tag" ELF section */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && - (bi->flags & BI_BRAND_NOTE) != 0) { + if (bi == NULL) + continue; + if (hdr->e_machine == bi->machine && (bi->flags & + (BI_BRAND_NOTE|BI_BRAND_NOTE_MANDATORY)) != 0) { ret = __elfN(check_note)(imgp, bi->brand_note, osrel); if (ret) return (bi); @@ -249,7 +251,9 @@ __elfN(get_brandinfo)(struct image_param /* If the executable has a brand, search for it in the brand list. */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && + if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) + continue; + if (hdr->e_machine == bi->machine && (hdr->e_ident[EI_OSABI] == bi->brand || strncmp((const char *)&hdr->e_ident[OLD_EI_BRAND], bi->compat_3_brand, strlen(bi->compat_3_brand)) == 0)) @@ -260,7 +264,9 @@ __elfN(get_brandinfo)(struct image_param if (interp != NULL) { for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && + if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) + continue; + if (hdr->e_machine == bi->machine && strcmp(interp, bi->interp_path) == 0) return (bi); } @@ -269,7 +275,9 @@ __elfN(get_brandinfo)(struct image_param /* Lacking a recognized interpreter, try the default brand */ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; - if (bi != NULL && hdr->e_machine == bi->machine && + if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY) + continue; + if (hdr->e_machine == bi->machine && __elfN(fallback_brand) == bi->brand) return (bi); } Modified: stable/8/sys/sys/imgact_elf.h ============================================================================== --- stable/8/sys/sys/imgact_elf.h Wed Sep 2 10:12:13 2009 (r196760) +++ stable/8/sys/sys/imgact_elf.h Wed Sep 2 10:39:46 2009 (r196761) @@ -74,8 +74,9 @@ typedef struct { const char *interp_newpath; int flags; Elf_Brandnote *brand_note; -#define BI_CAN_EXEC_DYN 0x0001 -#define BI_BRAND_NOTE 0x0002 +#define BI_CAN_EXEC_DYN 0x0001 +#define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */ +#define BI_BRAND_NOTE_MANDATORY 0x0004 /* Must have note.ABI-tag section. */ } __ElfN(Brandinfo); __ElfType(Auxargs); From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 15:14:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 278B91065679 for ; Wed, 2 Sep 2009 15:14:18 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id B4EB78FC1E for ; Wed, 2 Sep 2009 15:14:17 +0000 (UTC) Received: (qmail 22319 invoked by uid 399); 2 Sep 2009 15:14:12 -0000 Received: from localhost (HELO foreign.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 2 Sep 2009 15:14:12 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Message-ID: <4A9E8BBE.9060000@FreeBSD.org> Date: Wed, 02 Sep 2009 08:14:06 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 2.0.0.23 (X11/20090822) MIME-Version: 1.0 To: remko@elvandar.org References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> In-Reply-To: <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> X-Enigmail-Version: 0.96.0 OpenPGP: id=D5B2F0FB Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, Alfred Perlstein , src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 15:14:18 -0000 Remko Lodder wrote: > On Wed, September 2, 2009 4:12 am, Alfred Perlstein wrote: >> Author: alfred >> Date: Wed Sep 2 02:12:07 2009 >> New Revision: 196746 >> URL: http://svn.freebsd.org/changeset/base/196746 >> >> Log: >> MFC: r196489,196498 >> Critical USB bugfixes for 8.0 >> > > Dear Alfred (and hps!), > > It would be awesome to see something more about this in the commit log. I > needed to look up the specific revisions to see what changed. I always > learned from Warner and people, that including the original commit > message(s) saves a lot of time and makes it clear about what is being > merged. ... and I was taught that including the complete commit message is a waste of space since it already exists in HEAD, and therefore to summarize the changes briefly rather than reporting them verbatim. A philosophy with which I agree. :) There were only 2 changes merged, going back and looking at the logs for them could not have been that much of a burden. That said, for RELENG_8 commits during the freeze re@ did ask in one of their many messages about commit approvals to paste the complete commit message in the MFC. So, bad Alfred, no cookie. :) Doug -- This .signature sanitized for your protection From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 15:57:45 2009 Return-Path: Delivered-To: svn-src-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A94A21065676 for ; Wed, 2 Sep 2009 15:57:45 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx21.fluidhosting.com [204.14.89.4]) by mx1.freebsd.org (Postfix) with ESMTP id 507858FC12 for ; Wed, 2 Sep 2009 15:57:45 +0000 (UTC) Received: (qmail 7666 invoked by uid 399); 2 Sep 2009 15:57:42 -0000 Received: from localhost (HELO foreign.dougb.net) (dougb@dougbarton.us@127.0.0.1) by localhost with ESMTPAM; 2 Sep 2009 15:57:42 -0000 X-Originating-IP: 127.0.0.1 X-Sender: dougb@dougbarton.us Message-ID: <4A9E95F1.9070309@FreeBSD.org> Date: Wed, 02 Sep 2009 08:57:37 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 2.0.0.23 (X11/20090822) MIME-Version: 1.0 To: Ken Smith References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <4A9E8BBE.9060000@FreeBSD.org> <1251905775.24711.32.camel@bauer.cse.buffalo.edu> In-Reply-To: <1251905775.24711.32.camel@bauer.cse.buffalo.edu> X-Enigmail-Version: 0.96.0 OpenPGP: id=D5B2F0FB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: remko@elvandar.org, svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, Alfred Perlstein , src-committers@FreeBSD.org, svn-src-stable-8@FreeBSD.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 15:57:45 -0000 Ken Smith wrote: > On Wed, 2009-09-02 at 08:14 -0700, Doug Barton wrote: >> That said, for RELENG_8 commits during the freeze re@ did ask in one >> of their many messages about commit approvals to paste the complete >> commit message in the MFC. So, bad Alfred, no cookie. :) > > Just for clarification... We ask that you send your complete *proposed > commit message* in your *approval request*. We didn't say that your > commit message needs to include all of the text from the commit to head. > > So, bad Doug, no cookie. :-) -------- Original Message -------- Subject: Repost: approval request and merge guidelines during release cycle Date: Sun, 16 Aug 2009 10:29:58 +0100 (BST) From: Robert Watson To: developers@FreeBSD.org [...] 5. When committing the merge, include the original revision number (rXXXXXX) and a copy of the original commit message in the merge commit message. But you're the boss, so whatever you say goes. :) (I would like my cookie back though.) > FWIW my preference is, as usual, somewhere in between the two extremes. > Duplicating a lengthy commit message in a merge is overkill but in those > cases a short (one sentence max) summary of what changed being in the > merge commit message is helpful. For example when looking through the > commits for release notes fodder it can help. It also helps people who > take the peer review of commits being done seriously to get the warm > fuzzy feeling that the merge wasn't an accidental mis-merge (by seeing > that the code seems to match the brief description). Seriously though, I agree with you, and will be happy to continue complying with this policy going forward. :) Doug -- This .signature sanitized for your protection From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 16:03:30 2009 Return-Path: Delivered-To: svn-src-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A79601065672; Wed, 2 Sep 2009 16:03:30 +0000 (UTC) (envelope-from kensmith@cse.Buffalo.EDU) Received: from phoebe.cse.buffalo.edu (phoebe.cse.buffalo.edu [128.205.32.89]) by mx1.freebsd.org (Postfix) with ESMTP id 64F9A8FC27; Wed, 2 Sep 2009 16:03:30 +0000 (UTC) Received: from [128.205.32.76] (bauer.cse.buffalo.edu [128.205.32.76]) (authenticated bits=0) by phoebe.cse.buffalo.edu (8.14.1/8.13.7) with ESMTP id n82G2wBo090014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Sep 2009 12:03:01 -0400 (EDT) (envelope-from kensmith@cse.buffalo.edu) From: Ken Smith To: Doug Barton In-Reply-To: <4A9E95F1.9070309@FreeBSD.org> References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <4A9E8BBE.9060000@FreeBSD.org> <1251905775.24711.32.camel@bauer.cse.buffalo.edu> <4A9E95F1.9070309@FreeBSD.org> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-74OVSEqRNjMu4oO8M8IJ" Organization: U. Buffalo CSE Department Date: Wed, 02 Sep 2009 12:02:55 -0400 Message-Id: <1251907375.24711.38.camel@bauer.cse.buffalo.edu> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 FreeBSD GNOME Team Port X-DCC-Buffalo.EDU-Metrics: phoebe.cse.buffalo.edu 1029; Body=0 Fuz1=0 Fuz2=0 Cc: remko@elvandar.org, svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, Alfred Perlstein , src-committers@FreeBSD.org, svn-src-stable-8@FreeBSD.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 16:03:30 -0000 --=-74OVSEqRNjMu4oO8M8IJ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2009-09-02 at 08:57 -0700, Doug Barton wrote: > Subject: Repost: approval request and merge guidelines during release > cycle > Date: Sun, 16 Aug 2009 10:29:58 +0100 (BST) > From: Robert Watson > To: developers@FreeBSD.org >=20 > [...] >=20 > 5. When committing the merge, include the original revision number > (rXXXXXX) and a copy of the original commit message in the merge > commit message. >=20 > But you're the boss, so whatever you say goes. :) (I would like my > cookie back though.) Hrm. Get it from rwatson. :-/ --=20 Ken Smith - From there to here, from here to | kensmith@cse.buffalo.edu there, funny things are everywhere. | - Theodore Geisel | --=-74OVSEqRNjMu4oO8M8IJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEABECAAYFAkqely8ACgkQ/G14VSmup/ZO5ACfcSGib/hMV/KM1n1XYwOQM+cT EmUAn0tkz38vOH09Zd2Ig5kltPhrPl/e =a+j+ -----END PGP SIGNATURE----- --=-74OVSEqRNjMu4oO8M8IJ-- From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 16:07:34 2009 Return-Path: Delivered-To: svn-src-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 286E81065670; Wed, 2 Sep 2009 16:07:34 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from mail.farley.org (mail.farley.org [IPv6:2001:470:1f0f:20:2::11]) by mx1.freebsd.org (Postfix) with ESMTP id C03548FC13; Wed, 2 Sep 2009 16:07:33 +0000 (UTC) Received: from thor.farley.org (HPooka@thor.farley.org [IPv6:2001:470:1f0f:20:1::5]) by mail.farley.org (8.14.3/8.14.3) with ESMTP id n82G6qdh030615; Wed, 2 Sep 2009 11:06:52 -0500 (CDT) (envelope-from scf@FreeBSD.org) Date: Wed, 2 Sep 2009 11:06:52 -0500 (CDT) From: "Sean C. Farley" To: Ken Smith In-Reply-To: <1251905775.24711.32.camel@bauer.cse.buffalo.edu> Message-ID: References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <4A9E8BBE.9060000@FreeBSD.org> <1251905775.24711.32.camel@bauer.cse.buffalo.edu> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Spam-Status: No, score=-2.8 required=4.0 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail.farley.org Cc: Doug Barton , svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, Alfred Perlstein , remko@elvandar.org, svn-src-stable-8@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 16:07:34 -0000 On Wed, 2 Sep 2009, Ken Smith wrote: > On Wed, 2009-09-02 at 08:14 -0700, Doug Barton wrote: >> That said, for RELENG_8 commits during the freeze re@ did ask in one >> of their many messages about commit approvals to paste the complete >> commit message in the MFC. So, bad Alfred, no cookie. :) > > Just for clarification... We ask that you send your complete > *proposed commit message* in your *approval request*. We didn't say > that your commit message needs to include all of the text from the > commit to head. > > So, bad Doug, no cookie. :-) > > FWIW my preference is, as usual, somewhere in between the two > extremes. Duplicating a lengthy commit message in a merge is overkill > but in those cases a short (one sentence max) summary of what changed > being in the merge commit message is helpful. For example when > looking through the commits for release notes fodder it can help. It > also helps people who take the peer review of commits being done > seriously to get the warm fuzzy feeling that the merge wasn't an > accidental mis-merge (by seeing that the code seems to match the brief > description). Personally, I like to include the entire message to prevent having to scan the logs for the original commit(s), however, an alternative would be to have the MFC include a URL to the original commit. Two options would be: 1. Automatic insertion into log message with a Subversion hook which adds a URL from scanning a special code in the MFC message (MFC r12345,12346-12349). Of course, this takes more initial setup and education for committers (at least me :)) to use it correctly. 2. Committer can use a special base URL that is agreed to never change. This would make it easier to find the original log message without having to scan for it. Sean -- scf@FreeBSD.org From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 16:12:45 2009 Return-Path: Delivered-To: svn-src-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71C66106566C; Wed, 2 Sep 2009 16:12:45 +0000 (UTC) (envelope-from kensmith@cse.Buffalo.EDU) Received: from phoebe.cse.buffalo.edu (phoebe.cse.buffalo.edu [128.205.32.89]) by mx1.freebsd.org (Postfix) with ESMTP id 2D8478FC0A; Wed, 2 Sep 2009 16:12:44 +0000 (UTC) Received: from [128.205.32.76] (bauer.cse.buffalo.edu [128.205.32.76]) (authenticated bits=0) by phoebe.cse.buffalo.edu (8.14.1/8.13.7) with ESMTP id n82FaIAI089945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Sep 2009 11:36:27 -0400 (EDT) (envelope-from kensmith@cse.buffalo.edu) From: Ken Smith To: Doug Barton In-Reply-To: <4A9E8BBE.9060000@FreeBSD.org> References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <4A9E8BBE.9060000@FreeBSD.org> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-oEGsUu8QJtWkVXcXRaIs" Organization: U. Buffalo CSE Department Date: Wed, 02 Sep 2009 11:36:15 -0400 Message-Id: <1251905775.24711.32.camel@bauer.cse.buffalo.edu> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 FreeBSD GNOME Team Port X-DCC-Buffalo.EDU-Metrics: phoebe.cse.buffalo.edu 1335; Body=0 Fuz1=0 Fuz2=0 Cc: remko@elvandar.org, svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, Alfred Perlstein , src-committers@FreeBSD.org, svn-src-stable-8@FreeBSD.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 16:12:45 -0000 --=-oEGsUu8QJtWkVXcXRaIs Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2009-09-02 at 08:14 -0700, Doug Barton wrote: > That said, for RELENG_8 commits during the freeze re@ did ask in one > of their many messages about commit approvals to paste the complete > commit message in the MFC. So, bad Alfred, no cookie. :) Just for clarification... We ask that you send your complete *proposed commit message* in your *approval request*. We didn't say that your commit message needs to include all of the text from the commit to head. So, bad Doug, no cookie. :-) FWIW my preference is, as usual, somewhere in between the two extremes. Duplicating a lengthy commit message in a merge is overkill but in those cases a short (one sentence max) summary of what changed being in the merge commit message is helpful. For example when looking through the commits for release notes fodder it can help. It also helps people who take the peer review of commits being done seriously to get the warm fuzzy feeling that the merge wasn't an accidental mis-merge (by seeing that the code seems to match the brief description). --=20 Ken Smith - From there to here, from here to | kensmith@cse.buffalo.edu there, funny things are everywhere. | - Theodore Geisel | --=-oEGsUu8QJtWkVXcXRaIs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEABECAAYFAkqekOQACgkQ/G14VSmup/YWfQCfSnHu68c34PDsv+MGUw5LCkvs aAcAn3qSX4C2+6izZMbGIwsmKfvVZkRq =kamy -----END PGP SIGNATURE----- --=-oEGsUu8QJtWkVXcXRaIs-- From owner-svn-src-stable@FreeBSD.ORG Wed Sep 2 16:35:57 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3A001065692; Wed, 2 Sep 2009 16:35:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AFE488FC19; Wed, 2 Sep 2009 16:35:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n82GZvNb001553; Wed, 2 Sep 2009 16:35:57 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n82GZvjh001551; Wed, 2 Sep 2009 16:35:57 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200909021635.n82GZvjh001551@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 2 Sep 2009 16:35:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196770 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 16:35:58 -0000 Author: bz Date: Wed Sep 2 16:35:57 2009 New Revision: 196770 URL: http://svn.freebsd.org/changeset/base/196770 Log: MFC r196738: In case an upper layer protocol tries to send a packet but the L2 code does not have the ethernet address for the destination within the broadcast domain in the table, we remember the original mbuf in `la_hold' in arpresolve() and send out a different packet with an arp request. In case there will be more upper layer packets to send we will free an earlier one held in `la_hold' and queue the new one. Once we get a packet in, with which we can perfect our arp table entry we send out the original 'on hold' packet, should there be any. Rather than continuing to process the packet that we received, we returned without freeing the packet that came in, which basically means that we leaked an mbuf for every arp request we sent. Rather than freeing the received packet and returning, continue to process the incoming arp packet as well. This should (a) improve some setups, also proxy-arp, in case it was an incoming arp request and (b) resembles the behaviour FreeBSD had from day 1, which alignes with RFC826 "Packet reception" (merge case). Rename 'm0' to 'hold' to make the code more understandable as well as diffable to earlier versions more easily. Handle the link-layer entry 'la' lock comepletely in the block where needed and release it as early as possible, rather than holding it longer, down to the end of the function. Found by: pointyhat, ns1 Bug hunting session with: erwin, simon, rwatson Tested by: simon on cluster machines Reviewed by: ratson, kmacy, julian Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/if_ether.c Modified: stable/8/sys/netinet/if_ether.c ============================================================================== --- stable/8/sys/netinet/if_ether.c Wed Sep 2 16:02:48 2009 (r196769) +++ stable/8/sys/netinet/if_ether.c Wed Sep 2 16:35:57 2009 (r196770) @@ -462,11 +462,11 @@ in_arpinput(struct mbuf *m) struct rtentry *rt; struct ifaddr *ifa; struct in_ifaddr *ia; + struct mbuf *hold; struct sockaddr sa; struct in_addr isaddr, itaddr, myaddr; u_int8_t *enaddr = NULL; int op, flags; - struct mbuf *m0; int req_len; int bridged = 0, is_bridge = 0; #ifdef DEV_CARP @@ -631,11 +631,13 @@ match: la->lle_tbl->llt_ifp->if_xname, ifp->if_addrlen, (u_char *)ar_sha(ah), ":", ifp->if_xname); + LLE_WUNLOCK(la); goto reply; } if ((la->la_flags & LLE_VALID) && bcmp(ar_sha(ah), &la->ll_addr, ifp->if_addrlen)) { if (la->la_flags & LLE_STATIC) { + LLE_WUNLOCK(la); log(LOG_ERR, "arp: %*D attempts to modify permanent " "entry for %s on %s\n", @@ -655,6 +657,7 @@ match: } if (ifp->if_addrlen != ah->ar_hln) { + LLE_WUNLOCK(la); log(LOG_WARNING, "arp from %*D: addr len: new %d, i/f %d (ignored)", ifp->if_addrlen, (u_char *) ar_sha(ah), ":", @@ -671,15 +674,14 @@ match: } la->la_asked = 0; la->la_preempt = V_arp_maxtries; - if (la->la_hold != NULL) { - m0 = la->la_hold; - la->la_hold = 0; + hold = la->la_hold; + if (hold != NULL) { + la->la_hold = NULL; memcpy(&sa, L3_ADDR(la), sizeof(sa)); - LLE_WUNLOCK(la); - - (*ifp->if_output)(ifp, m0, &sa, NULL); - return; } + LLE_WUNLOCK(la); + if (hold != NULL) + (*ifp->if_output)(ifp, hold, &sa, NULL); } reply: if (op != ARPOP_REQUEST) @@ -750,8 +752,6 @@ reply: #endif } - if (la != NULL) - LLE_WUNLOCK(la); if (itaddr.s_addr == myaddr.s_addr && IN_LINKLOCAL(ntohl(itaddr.s_addr))) { /* RFC 3927 link-local IPv4; always reply by broadcast. */ @@ -777,8 +777,6 @@ reply: return; drop: - if (la != NULL) - LLE_WUNLOCK(la); m_freem(m); } #endif From owner-svn-src-stable@FreeBSD.ORG Thu Sep 3 09:44:40 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 328691065670; Thu, 3 Sep 2009 09:44:40 +0000 (UTC) (envelope-from simon@benji.nitro.dk) Received: from mx.nitro.dk (zarniwoop.nitro.dk [83.92.207.38]) by mx1.freebsd.org (Postfix) with ESMTP id DCA408FC2C; Thu, 3 Sep 2009 09:44:39 +0000 (UTC) Received: from benji.nitro.dk (unknown [192.168.3.39]) by mx.nitro.dk (Postfix) with ESMTP id 269A52D485F; Thu, 3 Sep 2009 09:44:39 +0000 (UTC) Received: by benji.nitro.dk (Postfix, from userid 2000) id 0DF9354C3; Thu, 3 Sep 2009 11:44:39 +0200 (CEST) Date: Thu, 3 Sep 2009 11:44:39 +0200 From: "Simon L. Nielsen" To: Doug Barton Message-ID: <20090903094438.GC1304@zaphod.nitro.dk> References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <4A9E8BBE.9060000@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A9E8BBE.9060000@FreeBSD.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: remko@elvandar.org, svn-src-stable@freebsd.org, svn-src-all@freebsd.org, Alfred Perlstein , src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 09:44:40 -0000 On 2009.09.02 08:14:06 -0700, Doug Barton wrote: > Remko Lodder wrote: > > On Wed, September 2, 2009 4:12 am, Alfred Perlstein wrote: > >> Author: alfred > >> Date: Wed Sep 2 02:12:07 2009 > >> New Revision: 196746 > >> URL: http://svn.freebsd.org/changeset/base/196746 > >> > >> Log: > >> MFC: r196489,196498 > >> Critical USB bugfixes for 8.0 > >> > > > > Dear Alfred (and hps!), > > > > It would be awesome to see something more about this in the commit log. I > > needed to look up the specific revisions to see what changed. I always > > learned from Warner and people, that including the original commit > > message(s) saves a lot of time and makes it clear about what is being > > merged. > > ... and I was taught that including the complete commit message is a > waste of space since it already exists in HEAD, and therefore to > summarize the changes briefly rather than reporting them verbatim. A > philosophy with which I agree. :) There were only 2 changes merged, > going back and looking at the logs for them could not have been that > much of a burden. FWIW, I like when there is a text describing the change for an MFC, because: - I don't have to go looking up more info when reading commit mails. - I don't have to go looking up more info when history X years later (this could of couse be dealt with in viewsvn if we wanted to). - If one accidently refer to the wrong revision number it is possible track down which change was MFC'ed by looking at the text. Also I don't see what space is being wasted... I agree at times it might make sense to summarize in case it's a long commit msg, but frankly I'm lazy and most of the time I just copy / paste the commit msg since it's simpler. Just my 0.01 DKK. -- Simon L. Nielsen From owner-svn-src-stable@FreeBSD.ORG Thu Sep 3 13:54:58 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A8E311065672; Thu, 3 Sep 2009 13:54:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9508C8FC2E; Thu, 3 Sep 2009 13:54:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n83Dswum034430; Thu, 3 Sep 2009 13:54:58 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n83DswuL034426; Thu, 3 Sep 2009 13:54:58 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909031354.n83DswuL034426@svn.freebsd.org> From: John Baldwin Date: Thu, 3 Sep 2009 13:54:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196780 - in stable/8/sys: . amd64/amd64 amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci i386/i386 i386/include X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 13:54:58 -0000 Author: jhb Date: Thu Sep 3 13:54:58 2009 New Revision: 196780 URL: http://svn.freebsd.org/changeset/base/196780 Log: MFC 196705 and 196707: - Improve pmap_change_attr() on i386 so that it is able to demote a large (2/4MB) page into 4KB pages as needed. This should be fairly rare in practice. - Simplify pmap_change_attr() a bit: - Always calculate the cache bits instead of doing it on-demand. - Always set changed to TRUE rather than only doing it if it is false. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/amd64/pmap.c stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/i386/i386/pmap.c stable/8/sys/i386/include/pmap.h Modified: stable/8/sys/amd64/amd64/pmap.c ============================================================================== --- stable/8/sys/amd64/amd64/pmap.c Thu Sep 3 13:40:41 2009 (r196779) +++ stable/8/sys/amd64/amd64/pmap.c Thu Sep 3 13:54:58 2009 (r196780) @@ -4476,7 +4476,8 @@ pmap_change_attr_locked(vm_offset_t va, if (base < DMAP_MIN_ADDRESS) return (EINVAL); - cache_bits_pde = cache_bits_pte = -1; + cache_bits_pde = pmap_cache_bits(mode, 1); + cache_bits_pte = pmap_cache_bits(mode, 0); changed = FALSE; /* @@ -4493,8 +4494,6 @@ pmap_change_attr_locked(vm_offset_t va, * memory type, then we need not demote this page. Just * increment tmpva to the next 1GB page frame. */ - if (cache_bits_pde < 0) - cache_bits_pde = pmap_cache_bits(mode, 1); if ((*pdpe & PG_PDE_CACHE) == cache_bits_pde) { tmpva = trunc_1gpage(tmpva) + NBPDP; continue; @@ -4522,8 +4521,6 @@ pmap_change_attr_locked(vm_offset_t va, * memory type, then we need not demote this page. Just * increment tmpva to the next 2MB page frame. */ - if (cache_bits_pde < 0) - cache_bits_pde = pmap_cache_bits(mode, 1); if ((*pde & PG_PDE_CACHE) == cache_bits_pde) { tmpva = trunc_2mpage(tmpva) + NBPDR; continue; @@ -4557,12 +4554,9 @@ pmap_change_attr_locked(vm_offset_t va, for (tmpva = base; tmpva < base + size; ) { pdpe = pmap_pdpe(kernel_pmap, tmpva); if (*pdpe & PG_PS) { - if (cache_bits_pde < 0) - cache_bits_pde = pmap_cache_bits(mode, 1); if ((*pdpe & PG_PDE_CACHE) != cache_bits_pde) { pmap_pde_attr(pdpe, cache_bits_pde); - if (!changed) - changed = TRUE; + changed = TRUE; } if (tmpva >= VM_MIN_KERNEL_ADDRESS) { if (pa_start == pa_end) { @@ -4588,12 +4582,9 @@ pmap_change_attr_locked(vm_offset_t va, } pde = pmap_pdpe_to_pde(pdpe, tmpva); if (*pde & PG_PS) { - if (cache_bits_pde < 0) - cache_bits_pde = pmap_cache_bits(mode, 1); if ((*pde & PG_PDE_CACHE) != cache_bits_pde) { pmap_pde_attr(pde, cache_bits_pde); - if (!changed) - changed = TRUE; + changed = TRUE; } if (tmpva >= VM_MIN_KERNEL_ADDRESS) { if (pa_start == pa_end) { @@ -4616,13 +4607,10 @@ pmap_change_attr_locked(vm_offset_t va, } tmpva = trunc_2mpage(tmpva) + NBPDR; } else { - if (cache_bits_pte < 0) - cache_bits_pte = pmap_cache_bits(mode, 0); pte = pmap_pde_to_pte(pde, tmpva); if ((*pte & PG_PTE_CACHE) != cache_bits_pte) { pmap_pte_attr(pte, cache_bits_pte); - if (!changed) - changed = TRUE; + changed = TRUE; } if (tmpva >= VM_MIN_KERNEL_ADDRESS) { if (pa_start == pa_end) { Modified: stable/8/sys/i386/i386/pmap.c ============================================================================== --- stable/8/sys/i386/i386/pmap.c Thu Sep 3 13:40:41 2009 (r196779) +++ stable/8/sys/i386/i386/pmap.c Thu Sep 3 13:54:58 2009 (r196780) @@ -288,12 +288,15 @@ static boolean_t pmap_enter_pde(pmap_t p static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, vm_page_t mpte); static void pmap_insert_pt_page(pmap_t pmap, vm_page_t mpte); +static void pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte); static boolean_t pmap_is_modified_pvh(struct md_page *pvh); static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); static vm_page_t pmap_lookup_pt_page(pmap_t pmap, vm_offset_t va); +static void pmap_pde_attr(pd_entry_t *pde, int cache_bits); static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va); static boolean_t pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t sva, vm_prot_t prot); +static void pmap_pte_attr(pt_entry_t *pte, int cache_bits); static void pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offset_t sva, vm_page_t *free); static int pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, vm_offset_t sva, @@ -2289,32 +2292,62 @@ pmap_pv_insert_pde(pmap_t pmap, vm_offse } /* - * Tries to demote a 2- or 4MB page mapping. + * Fills a page table page with mappings to consecutive physical pages. + */ +static void +pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte) +{ + pt_entry_t *pte; + + for (pte = firstpte; pte < firstpte + NPTEPG; pte++) { + *pte = newpte; + newpte += PAGE_SIZE; + } +} + +/* + * Tries to demote a 2- or 4MB page mapping. If demotion fails, the + * 2- or 4MB page mapping is invalidated. */ static boolean_t pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va) { pd_entry_t newpde, oldpde; pmap_t allpmaps_entry; - pt_entry_t *firstpte, newpte, *pte; + pt_entry_t *firstpte, newpte; vm_paddr_t mptepa; vm_page_t free, mpte; PMAP_LOCK_ASSERT(pmap, MA_OWNED); + oldpde = *pde; + KASSERT((oldpde & (PG_PS | PG_V)) == (PG_PS | PG_V), + ("pmap_demote_pde: oldpde is missing PG_PS and/or PG_V")); mpte = pmap_lookup_pt_page(pmap, va); if (mpte != NULL) pmap_remove_pt_page(pmap, mpte); else { - KASSERT((*pde & PG_W) == 0, + KASSERT((oldpde & PG_W) == 0, ("pmap_demote_pde: page table page for a wired mapping" " is missing")); - free = NULL; - pmap_remove_pde(pmap, pde, trunc_4mpage(va), &free); - pmap_invalidate_page(pmap, trunc_4mpage(va)); - pmap_free_zero_pages(free); - CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#x" - " in pmap %p", va, pmap); - return (FALSE); + + /* + * Invalidate the 2- or 4MB page mapping and return + * "failure" if the mapping was never accessed or the + * allocation of the new page table page fails. + */ + if ((oldpde & PG_A) == 0 || (mpte = vm_page_alloc(NULL, + va >> PDRSHIFT, VM_ALLOC_NOOBJ | VM_ALLOC_NORMAL | + VM_ALLOC_WIRED)) == NULL) { + free = NULL; + pmap_remove_pde(pmap, pde, trunc_4mpage(va), &free); + pmap_invalidate_page(pmap, trunc_4mpage(va)); + pmap_free_zero_pages(free); + CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#x" + " in pmap %p", va, pmap); + return (FALSE); + } + if (va < VM_MAXUSER_ADDRESS) + pmap->pm_stats.resident_count++; } mptepa = VM_PAGE_TO_PHYS(mpte); @@ -2348,30 +2381,32 @@ pmap_demote_pde(pmap_t pmap, pd_entry_t } firstpte = PADDR2; } - oldpde = *pde; newpde = mptepa | PG_M | PG_A | (oldpde & PG_U) | PG_RW | PG_V; - KASSERT((oldpde & (PG_A | PG_V)) == (PG_A | PG_V), - ("pmap_demote_pde: oldpde is missing PG_A and/or PG_V")); + KASSERT((oldpde & PG_A) != 0, + ("pmap_demote_pde: oldpde is missing PG_A")); KASSERT((oldpde & (PG_M | PG_RW)) != PG_RW, ("pmap_demote_pde: oldpde is missing PG_M")); - KASSERT((oldpde & PG_PS) != 0, - ("pmap_demote_pde: oldpde is missing PG_PS")); newpte = oldpde & ~PG_PS; if ((newpte & PG_PDE_PAT) != 0) newpte ^= PG_PDE_PAT | PG_PTE_PAT; /* - * If the mapping has changed attributes, update the page table - * entries. - */ + * If the page table page is new, initialize it. + */ + if (mpte->wire_count == 1) { + mpte->wire_count = NPTEPG; + pmap_fill_ptp(firstpte, newpte); + } KASSERT((*firstpte & PG_FRAME) == (newpte & PG_FRAME), ("pmap_demote_pde: firstpte and newpte map different physical" " addresses")); + + /* + * If the mapping has changed attributes, update the page table + * entries. + */ if ((*firstpte & PG_PTE_PROMOTE) != (newpte & PG_PTE_PROMOTE)) - for (pte = firstpte; pte < firstpte + NPTEPG; pte++) { - *pte = newpte; - newpte += PAGE_SIZE; - } + pmap_fill_ptp(firstpte, newpte); /* * Demote the mapping. This pmap is locked. The old PDE has @@ -4426,6 +4461,40 @@ pmap_clear_reference(vm_page_t m) * Miscellaneous support routines follow */ +/* Adjust the cache mode for a 4KB page mapped via a PTE. */ +static __inline void +pmap_pte_attr(pt_entry_t *pte, int cache_bits) +{ + u_int opte, npte; + + /* + * The cache mode bits are all in the low 32-bits of the + * PTE, so we can just spin on updating the low 32-bits. + */ + do { + opte = *(u_int *)pte; + npte = opte & ~PG_PTE_CACHE; + npte |= cache_bits; + } while (npte != opte && !atomic_cmpset_int((u_int *)pte, opte, npte)); +} + +/* Adjust the cache mode for a 2/4MB page mapped via a PDE. */ +static __inline void +pmap_pde_attr(pd_entry_t *pde, int cache_bits) +{ + u_int opde, npde; + + /* + * The cache mode bits are all in the low 32-bits of the + * PDE, so we can just spin on updating the low 32-bits. + */ + do { + opde = *(u_int *)pde; + npde = opde & ~PG_PDE_CACHE; + npde |= cache_bits; + } while (npde != opde && !atomic_cmpset_int((u_int *)pde, opde, npde)); +} + /* * Map a set of physical memory pages into the kernel virtual * address space. Return a pointer to where it is mapped. This @@ -4537,13 +4606,23 @@ pmap_page_set_memattr(vm_page_t m, vm_me } } +/* + * Changes the specified virtual address range's memory type to that given by + * the parameter "mode". The specified virtual address range must be + * completely contained within either the kernel map. + * + * Returns zero if the change completed successfully, and either EINVAL or + * ENOMEM if the change failed. Specifically, EINVAL is returned if some part + * of the virtual address range was not mapped, and ENOMEM is returned if + * there was insufficient memory available to complete the change. + */ int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode) { vm_offset_t base, offset, tmpva; - pt_entry_t *pte; - u_int opte, npte; pd_entry_t *pde; + pt_entry_t *pte; + int cache_bits_pte, cache_bits_pde; boolean_t changed; base = trunc_page(va); @@ -4556,47 +4635,84 @@ pmap_change_attr(vm_offset_t va, vm_size if (base < VM_MIN_KERNEL_ADDRESS) return (EINVAL); - /* 4MB pages and pages that aren't mapped aren't supported. */ - for (tmpva = base; tmpva < (base + size); tmpva += PAGE_SIZE) { + cache_bits_pde = pmap_cache_bits(mode, 1); + cache_bits_pte = pmap_cache_bits(mode, 0); + changed = FALSE; + + /* + * Pages that aren't mapped aren't supported. Also break down + * 2/4MB pages into 4KB pages if required. + */ + PMAP_LOCK(kernel_pmap); + for (tmpva = base; tmpva < base + size; ) { pde = pmap_pde(kernel_pmap, tmpva); - if (*pde & PG_PS) - return (EINVAL); - if (*pde == 0) + if (*pde == 0) { + PMAP_UNLOCK(kernel_pmap); return (EINVAL); + } + if (*pde & PG_PS) { + /* + * If the current 2/4MB page already has + * the required memory type, then we need not + * demote this page. Just increment tmpva to + * the next 2/4MB page frame. + */ + if ((*pde & PG_PDE_CACHE) == cache_bits_pde) { + tmpva = trunc_4mpage(tmpva) + NBPDR; + continue; + } + + /* + * If the current offset aligns with a 2/4MB + * page frame and there is at least 2/4MB left + * within the range, then we need not break + * down this page into 4KB pages. + */ + if ((tmpva & PDRMASK) == 0 && + tmpva + PDRMASK < base + size) { + tmpva += NBPDR; + continue; + } + if (!pmap_demote_pde(kernel_pmap, pde, tmpva)) { + PMAP_UNLOCK(kernel_pmap); + return (ENOMEM); + } + } pte = vtopte(tmpva); - if (*pte == 0) + if (*pte == 0) { + PMAP_UNLOCK(kernel_pmap); return (EINVAL); + } + tmpva += PAGE_SIZE; } - - changed = FALSE; + PMAP_UNLOCK(kernel_pmap); /* - * Ok, all the pages exist and are 4k, so run through them updating - * their cache mode. + * Ok, all the pages exist, so run through them updating their + * cache mode if required. */ - for (tmpva = base; size > 0; ) { - pte = vtopte(tmpva); - - /* - * The cache mode bits are all in the low 32-bits of the - * PTE, so we can just spin on updating the low 32-bits. - */ - do { - opte = *(u_int *)pte; - npte = opte & ~(PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT); - npte |= pmap_cache_bits(mode, 0); - } while (npte != opte && - !atomic_cmpset_int((u_int *)pte, opte, npte)); - if (npte != opte) - changed = TRUE; - tmpva += PAGE_SIZE; - size -= PAGE_SIZE; + for (tmpva = base; tmpva < base + size; ) { + pde = pmap_pde(kernel_pmap, tmpva); + if (*pde & PG_PS) { + if ((*pde & PG_PDE_CACHE) != cache_bits_pde) { + pmap_pde_attr(pde, cache_bits_pde); + changed = TRUE; + } + tmpva = trunc_4mpage(tmpva) + NBPDR; + } else { + pte = vtopte(tmpva); + if ((*pte & PG_PTE_CACHE) != cache_bits_pte) { + pmap_pte_attr(pte, cache_bits_pte); + changed = TRUE; + } + tmpva += PAGE_SIZE; + } } /* - * Flush CPU caches to make sure any data isn't cached that shouldn't - * be, etc. - */ + * Flush CPU caches to make sure any data isn't cached that + * shouldn't be, etc. + */ if (changed) { pmap_invalidate_range(kernel_pmap, base, tmpva); pmap_invalidate_cache_range(base, tmpva); Modified: stable/8/sys/i386/include/pmap.h ============================================================================== --- stable/8/sys/i386/include/pmap.h Thu Sep 3 13:40:41 2009 (r196779) +++ stable/8/sys/i386/include/pmap.h Thu Sep 3 13:54:58 2009 (r196780) @@ -81,6 +81,10 @@ #define PG_PROT (PG_RW|PG_U) /* all protection bits . */ #define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */ +/* Page level cache control fields used to determine the PAT type */ +#define PG_PDE_CACHE (PG_PDE_PAT | PG_NC_PWT | PG_NC_PCD) +#define PG_PTE_CACHE (PG_PTE_PAT | PG_NC_PWT | PG_NC_PCD) + /* * Promotion to a 2 or 4MB (PDE) page mapping requires that the corresponding * 4KB (PTE) page mappings have identical settings for the following fields: From owner-svn-src-stable@FreeBSD.ORG Thu Sep 3 13:56:19 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 455E6106566C; Thu, 3 Sep 2009 13:56:19 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 326BC8FC19; Thu, 3 Sep 2009 13:56:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n83DuJMq034511; Thu, 3 Sep 2009 13:56:19 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n83DuJ7P034506; Thu, 3 Sep 2009 13:56:19 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909031356.n83DuJ7P034506@svn.freebsd.org> From: John Baldwin Date: Thu, 3 Sep 2009 13:56:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196781 - in stable/7/sys: . amd64/amd64 amd64/include contrib/pf i386/i386 i386/include vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 13:56:19 -0000 Author: jhb Date: Thu Sep 3 13:56:18 2009 New Revision: 196781 URL: http://svn.freebsd.org/changeset/base/196781 Log: MFC 180430, 180483, 180485, 180601, 180845, 180871-180873, 181043, 181077, 181151, 181284, 181356, 181456, 189454, 194209, 195416, 195836, 196318, 196705, and 196707: Various fixes and enhancements to the amd64 and i386 pmaps to support PAT. - Extend pmap_demote_pde() to include the ability to instantiate a new page table page where none existed before. - Enhance pmap_change_attr() to fully support large (2/4MB) pages by breaking demoting them to 4KB page mappings when needed. - Enhance pmap_change_attr() to avoid page demotions, cache mode changes, and cache and TLB invalidation when some or all of the specified range is already mapped with the specified cache mode. - Enhance pmap_change_attr() to adjust the direct map automatically when changing the cache mode of a kernel virtual address range. - Fix pmap_object_init_pt() to not assume that the pages of a OBJT_DEVICE object are always physically contiguous. - Correct a critical accounting error in pmap_demote_pde(). Reviewed by: alc Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/amd64/pmap.c stable/7/sys/amd64/include/pmap.h stable/7/sys/contrib/pf/ (props changed) stable/7/sys/i386/i386/pmap.c stable/7/sys/i386/include/pmap.h stable/7/sys/vm/vm_object.c stable/7/sys/vm/vm_object.h Modified: stable/7/sys/amd64/amd64/pmap.c ============================================================================== --- stable/7/sys/amd64/amd64/pmap.c Thu Sep 3 13:54:58 2009 (r196780) +++ stable/7/sys/amd64/amd64/pmap.c Thu Sep 3 13:56:18 2009 (r196781) @@ -220,17 +220,22 @@ static void pmap_pvh_free(struct md_page static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap, vm_offset_t va); +static int pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode); static boolean_t pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va); static boolean_t pmap_enter_pde(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot); static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, vm_page_t mpte); +static void pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte); static void pmap_insert_pt_page(pmap_t pmap, vm_page_t mpte); static boolean_t pmap_is_modified_pvh(struct md_page *pvh); +static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); static vm_page_t pmap_lookup_pt_page(pmap_t pmap, vm_offset_t va); +static void pmap_pde_attr(pd_entry_t *pde, int cache_bits); static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va); static boolean_t pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t sva, vm_prot_t prot); +static void pmap_pte_attr(pt_entry_t *pte, int cache_bits); static int pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offset_t sva, vm_page_t *free); static int pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, @@ -461,11 +466,12 @@ create_pagetables(vm_paddr_t *firstaddr) ((pdp_entry_t *)KPDPphys)[i + KPDPI] |= PG_RW | PG_V | PG_U; } - /* Now set up the direct map space using 2MB pages */ + /* Preset PG_M and PG_A because demotion expects it */ for (i = 0; i < NPDEPG * ndmpdp; i++) { ((pd_entry_t *)DMPDphys)[i] = (vm_paddr_t)i << PDRSHIFT; - ((pd_entry_t *)DMPDphys)[i] |= PG_RW | PG_V | PG_PS | PG_G; + ((pd_entry_t *)DMPDphys)[i] |= PG_RW | PG_V | PG_PS | PG_G | + PG_M | PG_A; } /* And the direct map space's PDP */ @@ -1068,7 +1074,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p pte_store(pte, pa | PG_RW | PG_V | PG_G); } -PMAP_INLINE void +static __inline void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode) { pt_entry_t *pte; @@ -2192,58 +2198,98 @@ pmap_pv_insert_pde(pmap_t pmap, vm_offse } /* - * Tries to demote a 2MB page mapping. + * Fills a page table page with mappings to consecutive physical pages. + */ +static void +pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte) +{ + pt_entry_t *pte; + + for (pte = firstpte; pte < firstpte + NPTEPG; pte++) { + *pte = newpte; + newpte += PAGE_SIZE; + } +} + +/* + * Tries to demote a 2MB page mapping. If demotion fails, the 2MB page + * mapping is invalidated. */ static boolean_t pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va) { pd_entry_t newpde, oldpde; - pt_entry_t *firstpte, newpte, *pte; + pt_entry_t *firstpte, newpte; vm_paddr_t mptepa; vm_page_t free, mpte; PMAP_LOCK_ASSERT(pmap, MA_OWNED); + oldpde = *pde; + KASSERT((oldpde & (PG_PS | PG_V)) == (PG_PS | PG_V), + ("pmap_demote_pde: oldpde is missing PG_PS and/or PG_V")); mpte = pmap_lookup_pt_page(pmap, va); if (mpte != NULL) pmap_remove_pt_page(pmap, mpte); else { - KASSERT((*pde & PG_W) == 0, + KASSERT((oldpde & PG_W) == 0, ("pmap_demote_pde: page table page for a wired mapping" " is missing")); - free = NULL; - pmap_remove_pde(pmap, pde, trunc_2mpage(va), &free); - pmap_invalidate_page(pmap, trunc_2mpage(va)); - pmap_free_zero_pages(free); - CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#lx" - " in pmap %p", va, pmap); - return (FALSE); + + /* + * Invalidate the 2MB page mapping and return "failure" if the + * mapping was never accessed or the allocation of the new + * page table page fails. If the 2MB page mapping belongs to + * the direct map region of the kernel's address space, then + * the page allocation request specifies the highest possible + * priority (VM_ALLOC_INTERRUPT). Otherwise, the priority is + * normal. Page table pages are preallocated for every other + * part of the kernel address space, so the direct map region + * is the only part of the kernel address space that must be + * handled here. + */ + if ((oldpde & PG_A) == 0 || (mpte = vm_page_alloc(NULL, + pmap_pde_pindex(va), (va >= DMAP_MIN_ADDRESS && va < + DMAP_MAX_ADDRESS ? VM_ALLOC_INTERRUPT : VM_ALLOC_NORMAL) | + VM_ALLOC_NOOBJ | VM_ALLOC_WIRED)) == NULL) { + free = NULL; + pmap_remove_pde(pmap, pde, trunc_2mpage(va), &free); + pmap_invalidate_page(pmap, trunc_2mpage(va)); + pmap_free_zero_pages(free); + CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#lx" + " in pmap %p", va, pmap); + return (FALSE); + } + if (va < VM_MAXUSER_ADDRESS) + pmap->pm_stats.resident_count++; } mptepa = VM_PAGE_TO_PHYS(mpte); firstpte = (pt_entry_t *)PHYS_TO_DMAP(mptepa); - oldpde = *pde; newpde = mptepa | PG_M | PG_A | (oldpde & PG_U) | PG_RW | PG_V; - KASSERT((oldpde & (PG_A | PG_V)) == (PG_A | PG_V), - ("pmap_demote_pde: oldpde is missing PG_A and/or PG_V")); + KASSERT((oldpde & PG_A) != 0, + ("pmap_demote_pde: oldpde is missing PG_A")); KASSERT((oldpde & (PG_M | PG_RW)) != PG_RW, ("pmap_demote_pde: oldpde is missing PG_M")); - KASSERT((oldpde & PG_PS) != 0, - ("pmap_demote_pde: oldpde is missing PG_PS")); newpte = oldpde & ~PG_PS; if ((newpte & PG_PDE_PAT) != 0) newpte ^= PG_PDE_PAT | PG_PTE_PAT; /* - * If the mapping has changed attributes, update the page table - * entries. + * If the page table page is new, initialize it. */ + if (mpte->wire_count == 1) { + mpte->wire_count = NPTEPG; + pmap_fill_ptp(firstpte, newpte); + } KASSERT((*firstpte & PG_FRAME) == (newpte & PG_FRAME), ("pmap_demote_pde: firstpte and newpte map different physical" " addresses")); + + /* + * If the mapping has changed attributes, update the page table + * entries. + */ if ((*firstpte & PG_PTE_PROMOTE) != (newpte & PG_PTE_PROMOTE)) - for (pte = firstpte; pte < firstpte + NPTEPG; pte++) { - *pte = newpte; - newpte += PAGE_SIZE; - } + pmap_fill_ptp(firstpte, newpte); /* * Demote the mapping. This pmap is locked. The old PDE has @@ -3310,78 +3356,74 @@ void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object, vm_pindex_t pindex, vm_size_t size) { - vm_offset_t va; + pd_entry_t *pde; + vm_paddr_t pa, ptepa; vm_page_t p, pdpg; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); KASSERT(object->type == OBJT_DEVICE, ("pmap_object_init_pt: non-device object")); - if (((addr & (NBPDR - 1)) == 0) && ((size & (NBPDR - 1)) == 0)) { - vm_page_t m[1]; - pd_entry_t ptepa, *pde; - - PMAP_LOCK(pmap); - pde = pmap_pde(pmap, addr); - if (pde != 0 && (*pde & PG_V) != 0) - goto out; - PMAP_UNLOCK(pmap); -retry: + if ((addr & (NBPDR - 1)) == 0 && (size & (NBPDR - 1)) == 0) { + if (!vm_object_populate(object, pindex, pindex + atop(size))) + return; p = vm_page_lookup(object, pindex); - if (p != NULL) { - if (vm_page_sleep_if_busy(p, FALSE, "init4p")) - goto retry; - } else { - p = vm_page_alloc(object, pindex, VM_ALLOC_NORMAL); - if (p == NULL) - return; - m[0] = p; - - if (vm_pager_get_pages(object, m, 1, 0) != VM_PAGER_OK) { - vm_page_lock_queues(); - vm_page_free(p); - vm_page_unlock_queues(); - return; - } - - p = vm_page_lookup(object, pindex); - vm_page_wakeup(p); - } + KASSERT(p->valid == VM_PAGE_BITS_ALL, + ("pmap_object_init_pt: invalid page %p", p)); + /* + * Abort the mapping if the first page is not physically + * aligned to a 2MB page boundary. + */ ptepa = VM_PAGE_TO_PHYS(p); if (ptepa & (NBPDR - 1)) return; - p->valid = VM_PAGE_BITS_ALL; + /* + * Skip the first page. Abort the mapping if the rest of + * the pages are not physically contiguous. + */ + p = TAILQ_NEXT(p, listq); + for (pa = ptepa + PAGE_SIZE; pa < ptepa + size; + pa += PAGE_SIZE) { + KASSERT(p->valid == VM_PAGE_BITS_ALL, + ("pmap_object_init_pt: invalid page %p", p)); + if (pa != VM_PAGE_TO_PHYS(p)) + return; + p = TAILQ_NEXT(p, listq); + } + /* Map using 2MB pages. */ PMAP_LOCK(pmap); - for (va = addr; va < addr + size; va += NBPDR) { - while ((pdpg = - pmap_allocpde(pmap, va, M_NOWAIT)) == NULL) { - PMAP_UNLOCK(pmap); - vm_page_busy(p); - VM_OBJECT_UNLOCK(object); - VM_WAIT; - VM_OBJECT_LOCK(object); - vm_page_wakeup(p); - PMAP_LOCK(pmap); + for (pa = ptepa; pa < ptepa + size; pa += NBPDR) { + pdpg = pmap_allocpde(pmap, addr, M_NOWAIT); + if (pdpg == NULL) { + /* + * The creation of mappings below is only an + * optimization. If a page directory page + * cannot be allocated without blocking, + * continue on to the next mapping rather than + * blocking. + */ + addr += NBPDR; + continue; } pde = (pd_entry_t *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(pdpg)); - pde = &pde[pmap_pde_index(va)]; + pde = &pde[pmap_pde_index(addr)]; if ((*pde & PG_V) == 0) { - pde_store(pde, ptepa | PG_PS | PG_M | PG_A | + pde_store(pde, pa | PG_PS | PG_M | PG_A | PG_U | PG_RW | PG_V); - pmap->pm_stats.resident_count += - NBPDR / PAGE_SIZE; + pmap->pm_stats.resident_count += NBPDR / + PAGE_SIZE; + pmap_pde_mappings++; } else { + /* Continue on if the PDE is already valid. */ pdpg->wire_count--; KASSERT(pdpg->wire_count > 0, ("pmap_object_init_pt: missing reference " - "to page directory page, va: 0x%lx", va)); + "to page directory page, va: 0x%lx", addr)); } - ptepa += NBPDR; + addr += NBPDR; } - pmap_invalidate_all(pmap); -out: PMAP_UNLOCK(pmap); } } @@ -3739,7 +3781,9 @@ pmap_remove_pages(pmap_t pmap) if ((tpte & PG_PS) != 0) pte = pde; else { - pte = vtopte(pv->pv_va); + pte = (pt_entry_t *)PHYS_TO_DMAP(tpte & + PG_FRAME); + pte = &pte[pmap_pte_index(pv->pv_va)]; tpte = *pte & ~PG_PTE_PAT; } @@ -4160,41 +4204,35 @@ pmap_clear_reference(vm_page_t m) /* Adjust the cache mode for a 4KB page mapped via a PTE. */ static __inline void -pmap_pte_attr(vm_offset_t va, int mode) +pmap_pte_attr(pt_entry_t *pte, int cache_bits) { - pt_entry_t *pte; u_int opte, npte; - pte = vtopte(va); - /* * The cache mode bits are all in the low 32-bits of the * PTE, so we can just spin on updating the low 32-bits. */ do { opte = *(u_int *)pte; - npte = opte & ~(PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT); - npte |= pmap_cache_bits(mode, 0); + npte = opte & ~PG_PTE_CACHE; + npte |= cache_bits; } while (npte != opte && !atomic_cmpset_int((u_int *)pte, opte, npte)); } /* Adjust the cache mode for a 2MB page mapped via a PDE. */ static __inline void -pmap_pde_attr(vm_offset_t va, int mode) +pmap_pde_attr(pd_entry_t *pde, int cache_bits) { - pd_entry_t *pde; u_int opde, npde; - pde = pmap_pde(kernel_pmap, va); - /* * The cache mode bits are all in the low 32-bits of the * PDE, so we can just spin on updating the low 32-bits. */ do { opde = *(u_int *)pde; - npde = opde & ~(PG_PDE_PAT | PG_NC_PCD | PG_NC_PWT); - npde |= pmap_cache_bits(mode, 1); + npde = opde & ~PG_PDE_CACHE; + npde |= cache_bits; } while (npde != opde && !atomic_cmpset_int((u_int *)pde, opde, npde)); } @@ -4210,11 +4248,14 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_ vm_offset_t va, tmpva, offset; /* - * If this fits within the direct map window and use WB caching - * mode, use the direct map. + * If the specified range of physical addresses fits within the direct + * map window, use the direct map. */ - if (pa < dmaplimit && (pa + size) < dmaplimit && mode == PAT_WRITE_BACK) - return ((void *)PHYS_TO_DMAP(pa)); + if (pa < dmaplimit && pa + size < dmaplimit) { + va = PHYS_TO_DMAP(pa); + if (!pmap_change_attr(va, size, mode)) + return ((void *)va); + } offset = pa & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); va = kmem_alloc_nofault(kernel_map, size); @@ -4263,68 +4304,174 @@ pmap_unmapdev(vm_offset_t va, vm_size_t kmem_free(kernel_map, base, size); } +/* + * Changes the specified virtual address range's memory type to that given by + * the parameter "mode". The specified virtual address range must be + * completely contained within either the direct map or the kernel map. If + * the virtual address range is contained within the kernel map, then the + * memory type for each of the corresponding ranges of the direct map is also + * changed. (The corresponding ranges of the direct map are those ranges that + * map the same physical pages as the specified virtual address range.) These + * changes to the direct map are necessary because Intel describes the + * behavior of their processors as "undefined" if two or more mappings to the + * same physical page have different memory types. + * + * Returns zero if the change completed successfully, and either EINVAL or + * ENOMEM if the change failed. Specifically, EINVAL is returned if some part + * of the virtual address range was not mapped, and ENOMEM is returned if + * there was insufficient memory available to complete the change. In the + * latter case, the memory type may have been changed on some part of the + * virtual address range or the direct map. + */ int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode) { + int error; + + PMAP_LOCK(kernel_pmap); + error = pmap_change_attr_locked(va, size, mode); + PMAP_UNLOCK(kernel_pmap); + return (error); +} + +static int +pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode) +{ vm_offset_t base, offset, tmpva; + vm_paddr_t pa_start, pa_end; pd_entry_t *pde; pt_entry_t *pte; + int cache_bits_pte, cache_bits_pde, error; + boolean_t changed; + PMAP_LOCK_ASSERT(kernel_pmap, MA_OWNED); base = trunc_page(va); offset = va & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); - /* Only supported on kernel virtual addresses. */ - if (base <= VM_MAXUSER_ADDRESS) + /* + * Only supported on kernel virtual addresses, including the direct + * map but excluding the recursive map. + */ + if (base < DMAP_MIN_ADDRESS) return (EINVAL); + cache_bits_pde = pmap_cache_bits(mode, 1); + cache_bits_pte = pmap_cache_bits(mode, 0); + changed = FALSE; + /* - * XXX: We have to support tearing 2MB pages down into 4k pages if - * needed here. + * Pages that aren't mapped aren't supported. Also break down 2MB pages + * into 4KB pages if required. */ - /* Pages that aren't mapped aren't supported. */ - for (tmpva = base; tmpva < (base + size); ) { + for (tmpva = base; tmpva < base + size; ) { pde = pmap_pde(kernel_pmap, tmpva); if (*pde == 0) return (EINVAL); if (*pde & PG_PS) { - /* Handle 2MB pages that are completely contained. */ - if (size >= NBPDR) { + /* + * If the current 2MB page already has the required + * memory type, then we need not demote this page. Just + * increment tmpva to the next 2MB page frame. + */ + if ((*pde & PG_PDE_CACHE) == cache_bits_pde) { + tmpva = trunc_2mpage(tmpva) + NBPDR; + continue; + } + + /* + * If the current offset aligns with a 2MB page frame + * and there is at least 2MB left within the range, then + * we need not break down this page into 4KB pages. + */ + if ((tmpva & PDRMASK) == 0 && + tmpva + PDRMASK < base + size) { tmpva += NBPDR; continue; } - return (EINVAL); + if (!pmap_demote_pde(kernel_pmap, pde, tmpva)) + return (ENOMEM); } - pte = vtopte(va); + pte = pmap_pde_to_pte(pde, tmpva); if (*pte == 0) return (EINVAL); tmpva += PAGE_SIZE; } + error = 0; /* * Ok, all the pages exist, so run through them updating their - * cache mode. + * cache mode if required. */ - for (tmpva = base; size > 0; ) { + pa_start = pa_end = 0; + for (tmpva = base; tmpva < base + size; ) { pde = pmap_pde(kernel_pmap, tmpva); if (*pde & PG_PS) { - pmap_pde_attr(tmpva, mode); - tmpva += NBPDR; - size -= NBPDR; + if ((*pde & PG_PDE_CACHE) != cache_bits_pde) { + pmap_pde_attr(pde, cache_bits_pde); + changed = TRUE; + } + if (tmpva >= VM_MIN_KERNEL_ADDRESS) { + if (pa_start == pa_end) { + /* Start physical address run. */ + pa_start = *pde & PG_PS_FRAME; + pa_end = pa_start + NBPDR; + } else if (pa_end == (*pde & PG_PS_FRAME)) + pa_end += NBPDR; + else { + /* Run ended, update direct map. */ + error = pmap_change_attr_locked( + PHYS_TO_DMAP(pa_start), + pa_end - pa_start, mode); + if (error != 0) + break; + /* Start physical address run. */ + pa_start = *pde & PG_PS_FRAME; + pa_end = pa_start + NBPDR; + } + } + tmpva = trunc_2mpage(tmpva) + NBPDR; } else { - pmap_pte_attr(tmpva, mode); + pte = pmap_pde_to_pte(pde, tmpva); + if ((*pte & PG_PTE_CACHE) != cache_bits_pte) { + pmap_pte_attr(pte, cache_bits_pte); + changed = TRUE; + } + if (tmpva >= VM_MIN_KERNEL_ADDRESS) { + if (pa_start == pa_end) { + /* Start physical address run. */ + pa_start = *pte & PG_FRAME; + pa_end = pa_start + PAGE_SIZE; + } else if (pa_end == (*pte & PG_FRAME)) + pa_end += PAGE_SIZE; + else { + /* Run ended, update direct map. */ + error = pmap_change_attr_locked( + PHYS_TO_DMAP(pa_start), + pa_end - pa_start, mode); + if (error != 0) + break; + /* Start physical address run. */ + pa_start = *pte & PG_FRAME; + pa_end = pa_start + PAGE_SIZE; + } + } tmpva += PAGE_SIZE; - size -= PAGE_SIZE; } } + if (error == 0 && pa_start != pa_end) + error = pmap_change_attr_locked(PHYS_TO_DMAP(pa_start), + pa_end - pa_start, mode); /* - * Flush CPU caches to make sure any data isn't cached that shouldn't - * be, etc. - */ - pmap_invalidate_range(kernel_pmap, base, tmpva); - pmap_invalidate_cache(); - return (0); + * Flush CPU caches if required to make sure any data isn't cached that + * shouldn't be, etc. + */ + if (changed) { + pmap_invalidate_range(kernel_pmap, base, tmpva); + pmap_invalidate_cache(); + } + return (error); } /* Modified: stable/7/sys/amd64/include/pmap.h ============================================================================== --- stable/7/sys/amd64/include/pmap.h Thu Sep 3 13:54:58 2009 (r196780) +++ stable/7/sys/amd64/include/pmap.h Thu Sep 3 13:56:18 2009 (r196781) @@ -75,6 +75,10 @@ #define PG_PROT (PG_RW|PG_U) /* all protection bits . */ #define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */ +/* Page level cache control fields used to determine the PAT type */ +#define PG_PDE_CACHE (PG_PDE_PAT | PG_NC_PWT | PG_NC_PCD) +#define PG_PTE_CACHE (PG_PTE_PAT | PG_NC_PWT | PG_NC_PCD) + /* * Promotion to a 2MB (PDE) page mapping requires that the corresponding 4KB * (PTE) page mappings have identical settings for the following fields: @@ -308,7 +312,6 @@ void pmap_bootstrap(vm_paddr_t *); int pmap_change_attr(vm_offset_t, vm_size_t, int); void pmap_init_pat(void); void pmap_kenter(vm_offset_t va, vm_paddr_t pa); -void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); void *pmap_kenter_temporary(vm_paddr_t pa, int i); vm_paddr_t pmap_kextract(vm_offset_t); void pmap_kremove(vm_offset_t); Modified: stable/7/sys/i386/i386/pmap.c ============================================================================== --- stable/7/sys/i386/i386/pmap.c Thu Sep 3 13:54:58 2009 (r196780) +++ stable/7/sys/i386/i386/pmap.c Thu Sep 3 13:56:18 2009 (r196781) @@ -284,11 +284,15 @@ static boolean_t pmap_enter_pde(pmap_t p static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot, vm_page_t mpte); static void pmap_insert_pt_page(pmap_t pmap, vm_page_t mpte); +static void pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte); static boolean_t pmap_is_modified_pvh(struct md_page *pvh); +static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); static vm_page_t pmap_lookup_pt_page(pmap_t pmap, vm_offset_t va); +static void pmap_pde_attr(pd_entry_t *pde, int cache_bits); static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va); static boolean_t pmap_protect_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t sva, vm_prot_t prot); +static void pmap_pte_attr(pt_entry_t *pte, int cache_bits); static void pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offset_t sva, vm_page_t *free); static int pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, vm_offset_t sva, @@ -1132,7 +1136,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p pte_store(pte, pa | PG_RW | PG_V | pgeflag); } -PMAP_INLINE void +static __inline void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode) { pt_entry_t *pte; @@ -2245,32 +2249,62 @@ pmap_pv_insert_pde(pmap_t pmap, vm_offse } /* - * Tries to demote a 2- or 4MB page mapping. + * Fills a page table page with mappings to consecutive physical pages. + */ +static void +pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte) +{ + pt_entry_t *pte; + + for (pte = firstpte; pte < firstpte + NPTEPG; pte++) { + *pte = newpte; + newpte += PAGE_SIZE; + } +} + +/* + * Tries to demote a 2- or 4MB page mapping. If demotion fails, the + * 2- or 4MB page mapping is invalidated. */ static boolean_t pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va) { pd_entry_t newpde, oldpde; pmap_t allpmaps_entry; - pt_entry_t *firstpte, newpte, *pte; + pt_entry_t *firstpte, newpte; vm_paddr_t mptepa; vm_page_t free, mpte; PMAP_LOCK_ASSERT(pmap, MA_OWNED); + oldpde = *pde; + KASSERT((oldpde & (PG_PS | PG_V)) == (PG_PS | PG_V), + ("pmap_demote_pde: oldpde is missing PG_PS and/or PG_V")); mpte = pmap_lookup_pt_page(pmap, va); if (mpte != NULL) pmap_remove_pt_page(pmap, mpte); else { - KASSERT((*pde & PG_W) == 0, + KASSERT((oldpde & PG_W) == 0, ("pmap_demote_pde: page table page for a wired mapping" " is missing")); - free = NULL; - pmap_remove_pde(pmap, pde, trunc_4mpage(va), &free); - pmap_invalidate_page(pmap, trunc_4mpage(va)); - pmap_free_zero_pages(free); - CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#x" - " in pmap %p", va, pmap); - return (FALSE); + + /* + * Invalidate the 2- or 4MB page mapping and return + * "failure" if the mapping was never accessed or the + * allocation of the new page table page fails. + */ + if ((oldpde & PG_A) == 0 || (mpte = vm_page_alloc(NULL, + va >> PDRSHIFT, VM_ALLOC_NOOBJ | VM_ALLOC_NORMAL | + VM_ALLOC_WIRED)) == NULL) { + free = NULL; + pmap_remove_pde(pmap, pde, trunc_4mpage(va), &free); + pmap_invalidate_page(pmap, trunc_4mpage(va)); + pmap_free_zero_pages(free); + CTR2(KTR_PMAP, "pmap_demote_pde: failure for va %#x" + " in pmap %p", va, pmap); + return (FALSE); + } + if (va < VM_MAXUSER_ADDRESS) + pmap->pm_stats.resident_count++; } mptepa = VM_PAGE_TO_PHYS(mpte); @@ -2304,30 +2338,32 @@ pmap_demote_pde(pmap_t pmap, pd_entry_t } firstpte = PADDR2; } - oldpde = *pde; newpde = mptepa | PG_M | PG_A | (oldpde & PG_U) | PG_RW | PG_V; - KASSERT((oldpde & (PG_A | PG_V)) == (PG_A | PG_V), - ("pmap_demote_pde: oldpde is missing PG_A and/or PG_V")); + KASSERT((oldpde & PG_A) != 0, + ("pmap_demote_pde: oldpde is missing PG_A")); KASSERT((oldpde & (PG_M | PG_RW)) != PG_RW, ("pmap_demote_pde: oldpde is missing PG_M")); - KASSERT((oldpde & PG_PS) != 0, - ("pmap_demote_pde: oldpde is missing PG_PS")); newpte = oldpde & ~PG_PS; if ((newpte & PG_PDE_PAT) != 0) newpte ^= PG_PDE_PAT | PG_PTE_PAT; /* - * If the mapping has changed attributes, update the page table - * entries. - */ + * If the page table page is new, initialize it. + */ + if (mpte->wire_count == 1) { + mpte->wire_count = NPTEPG; + pmap_fill_ptp(firstpte, newpte); + } KASSERT((*firstpte & PG_FRAME) == (newpte & PG_FRAME), ("pmap_demote_pde: firstpte and newpte map different physical" " addresses")); + + /* + * If the mapping has changed attributes, update the page table + * entries. + */ if ((*firstpte & PG_PTE_PROMOTE) != (newpte & PG_PTE_PROMOTE)) - for (pte = firstpte; pte < firstpte + NPTEPG; pte++) { - *pte = newpte; - newpte += PAGE_SIZE; - } + pmap_fill_ptp(firstpte, newpte); /* * Demote the mapping. This pmap is locked. The old PDE has @@ -3432,62 +3468,57 @@ void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object, vm_pindex_t pindex, vm_size_t size) { + pd_entry_t *pde; + vm_paddr_t pa, ptepa; vm_page_t p; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); KASSERT(object->type == OBJT_DEVICE, ("pmap_object_init_pt: non-device object")); if (pseflag && - ((addr & (NBPDR - 1)) == 0) && ((size & (NBPDR - 1)) == 0)) { - int i; - vm_page_t m[1]; - unsigned int ptepindex; - int npdes; - pd_entry_t ptepa; - - PMAP_LOCK(pmap); - if (pmap->pm_pdir[ptepindex = (addr >> PDRSHIFT)]) - goto out; - PMAP_UNLOCK(pmap); -retry: + (addr & (NBPDR - 1)) == 0 && (size & (NBPDR - 1)) == 0) { + if (!vm_object_populate(object, pindex, pindex + atop(size))) + return; p = vm_page_lookup(object, pindex); - if (p != NULL) { - if (vm_page_sleep_if_busy(p, FALSE, "init4p")) - goto retry; - } else { - p = vm_page_alloc(object, pindex, VM_ALLOC_NORMAL); - if (p == NULL) - return; - m[0] = p; - - if (vm_pager_get_pages(object, m, 1, 0) != VM_PAGER_OK) { - vm_page_lock_queues(); - vm_page_free(p); - vm_page_unlock_queues(); - return; - } - - p = vm_page_lookup(object, pindex); - vm_page_wakeup(p); - } + KASSERT(p->valid == VM_PAGE_BITS_ALL, + ("pmap_object_init_pt: invalid page %p", p)); + /* + * Abort the mapping if the first page is not physically + * aligned to a 2/4MB page boundary. + */ ptepa = VM_PAGE_TO_PHYS(p); if (ptepa & (NBPDR - 1)) return; - p->valid = VM_PAGE_BITS_ALL; + /* + * Skip the first page. Abort the mapping if the rest of + * the pages are not physically contiguous. + */ + p = TAILQ_NEXT(p, listq); + for (pa = ptepa + PAGE_SIZE; pa < ptepa + size; + pa += PAGE_SIZE) { + KASSERT(p->valid == VM_PAGE_BITS_ALL, + ("pmap_object_init_pt: invalid page %p", p)); + if (pa != VM_PAGE_TO_PHYS(p)) + return; + p = TAILQ_NEXT(p, listq); + } + /* Map using 2/4MB pages. */ PMAP_LOCK(pmap); - pmap->pm_stats.resident_count += size >> PAGE_SHIFT; - npdes = size >> PDRSHIFT; - for(i = 0; i < npdes; i++) { - pde_store(&pmap->pm_pdir[ptepindex], - ptepa | PG_U | PG_RW | PG_V | PG_PS); - ptepa += NBPDR; - ptepindex += 1; + for (pa = ptepa; pa < ptepa + size; pa += NBPDR) { + pde = pmap_pde(pmap, addr); + if (*pde == 0) { + pde_store(pde, pa | PG_PS | PG_M | PG_A | + PG_U | PG_RW | PG_V); + pmap->pm_stats.resident_count += NBPDR / + PAGE_SIZE; + pmap_pde_mappings++; + } + /* Else continue on if the PDE is already valid. */ + addr += NBPDR; } - pmap_invalidate_all(pmap); -out: PMAP_UNLOCK(pmap); } } @@ -4326,6 +4357,40 @@ pmap_clear_reference(vm_page_t m) * Miscellaneous support routines follow */ +/* Adjust the cache mode for a 4KB page mapped via a PTE. */ +static __inline void +pmap_pte_attr(pt_entry_t *pte, int cache_bits) +{ + u_int opte, npte; + + /* + * The cache mode bits are all in the low 32-bits of the + * PTE, so we can just spin on updating the low 32-bits. + */ + do { + opte = *(u_int *)pte; + npte = opte & ~PG_PTE_CACHE; + npte |= cache_bits; + } while (npte != opte && !atomic_cmpset_int((u_int *)pte, opte, npte)); +} + +/* Adjust the cache mode for a 2/4MB page mapped via a PDE. */ +static __inline void +pmap_pde_attr(pd_entry_t *pde, int cache_bits) +{ + u_int opde, npde; + + /* + * The cache mode bits are all in the low 32-bits of the + * PDE, so we can just spin on updating the low 32-bits. + */ + do { + opde = *(u_int *)pde; + npde = opde & ~PG_PDE_CACHE; + npde |= cache_bits; + } while (npde != opde && !atomic_cmpset_int((u_int *)pde, opde, npde)); +} + /* * Map a set of physical memory pages into the kernel virtual * address space. Return a pointer to where it is mapped. This @@ -4389,61 +4454,117 @@ pmap_unmapdev(vm_offset_t va, vm_size_t kmem_free(kernel_map, base, size); } +/* + * Changes the specified virtual address range's memory type to that given by + * the parameter "mode". The specified virtual address range must be + * completely contained within either the kernel map. + * + * Returns zero if the change completed successfully, and either EINVAL or + * ENOMEM if the change failed. Specifically, EINVAL is returned if some part + * of the virtual address range was not mapped, and ENOMEM is returned if + * there was insufficient memory available to complete the change. + */ int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode) { vm_offset_t base, offset, tmpva; - pt_entry_t *pte; - u_int opte, npte; pd_entry_t *pde; + pt_entry_t *pte; + int cache_bits_pte, cache_bits_pde; + boolean_t changed; base = trunc_page(va); offset = va & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); - /* Only supported on kernel virtual addresses. */ - if (base <= VM_MAXUSER_ADDRESS) + /* + * Only supported on kernel virtual addresses above the recursive map. + */ + if (base < VM_MIN_KERNEL_ADDRESS) return (EINVAL); - /* 4MB pages and pages that aren't mapped aren't supported. */ - for (tmpva = base; tmpva < (base + size); tmpva += PAGE_SIZE) { + cache_bits_pde = pmap_cache_bits(mode, 1); + cache_bits_pte = pmap_cache_bits(mode, 0); + changed = FALSE; + + /* + * Pages that aren't mapped aren't supported. Also break down + * 2/4MB pages into 4KB pages if required. + */ + PMAP_LOCK(kernel_pmap); + for (tmpva = base; tmpva < base + size; ) { pde = pmap_pde(kernel_pmap, tmpva); - if (*pde & PG_PS) - return (EINVAL); - if (*pde == 0) + if (*pde == 0) { + PMAP_UNLOCK(kernel_pmap); return (EINVAL); - pte = vtopte(va); - if (*pte == 0) + } + if (*pde & PG_PS) { + /* + * If the current 2/4MB page already has + * the required memory type, then we need not + * demote this page. Just increment tmpva to + * the next 2/4MB page frame. + */ + if ((*pde & PG_PDE_CACHE) == cache_bits_pde) { + tmpva = trunc_4mpage(tmpva) + NBPDR; + continue; + } + + /* + * If the current offset aligns with a 2/4MB + * page frame and there is at least 2/4MB left + * within the range, then we need not break + * down this page into 4KB pages. + */ + if ((tmpva & PDRMASK) == 0 && + tmpva + PDRMASK < base + size) { + tmpva += NBPDR; + continue; + } + if (!pmap_demote_pde(kernel_pmap, pde, tmpva)) { + PMAP_UNLOCK(kernel_pmap); + return (ENOMEM); + } + } + pte = vtopte(tmpva); + if (*pte == 0) { + PMAP_UNLOCK(kernel_pmap); return (EINVAL); + } + tmpva += PAGE_SIZE; } + PMAP_UNLOCK(kernel_pmap); /* - * Ok, all the pages exist and are 4k, so run through them updating - * their cache mode. + * Ok, all the pages exist, so run through them updating their + * cache mode if required. */ - for (tmpva = base; size > 0; ) { - pte = vtopte(tmpva); - - /* - * The cache mode bits are all in the low 32-bits of the - * PTE, so we can just spin on updating the low 32-bits. - */ - do { - opte = *(u_int *)pte; - npte = opte & ~(PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT); - npte |= pmap_cache_bits(mode, 0); - } while (npte != opte && - !atomic_cmpset_int((u_int *)pte, opte, npte)); - tmpva += PAGE_SIZE; - size -= PAGE_SIZE; + for (tmpva = base; tmpva < base + size; ) { + pde = pmap_pde(kernel_pmap, tmpva); + if (*pde & PG_PS) { + if ((*pde & PG_PDE_CACHE) != cache_bits_pde) { + pmap_pde_attr(pde, cache_bits_pde); + changed = TRUE; + } + tmpva = trunc_4mpage(tmpva) + NBPDR; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Thu Sep 3 14:23:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DA3A106566C; Thu, 3 Sep 2009 14:23:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B03F8FC19; Thu, 3 Sep 2009 14:23:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n83ENpso035319; Thu, 3 Sep 2009 14:23:51 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n83ENpUW035318; Thu, 3 Sep 2009 14:23:51 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909031423.n83ENpUW035318@svn.freebsd.org> From: John Baldwin Date: Thu, 3 Sep 2009 14:23:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196782 - in stable/7/sys: . contrib/pf kern sys vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 14:23:51 -0000 Author: jhb Date: Thu Sep 3 14:23:50 2009 New Revision: 196782 URL: http://svn.freebsd.org/changeset/base/196782 Log: MFC 193275 and 194989: Add an extension to the character device interface that allows character device drivers to use arbitrary VM objects to satisfy individual mmap() requests. - A new d_mmap_single(cdev, &foff, objsize, &object, prot) callback is added to cdevsw. This function is called for each mmap() request. If it returns ENODEV, then the mmap() request will fall back to using the device's device pager object and d_mmap(). Otherwise, the method can return a VM object to satisfy this entire mmap() request via *object. It can also modify the starting offset into this object via *foff. This allows device drivers to use the file offset as a cookie to identify specific VM objects. - vm_mmap_vnode() has been changed to call vm_mmap_cdev() directly when mapping V_CHR vnodes. This avoids duplicating all the cdev mmap handling code and simplifies some of vm_mmap_vnode(). - D_VERSION has been bumped to D_VERSION_02. Older device drivers using D_VERSION_01 are still supported. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/kern_conf.c stable/7/sys/sys/conf.h stable/7/sys/vm/vm_mmap.c Modified: stable/7/sys/kern/kern_conf.c ============================================================================== --- stable/7/sys/kern/kern_conf.c Thu Sep 3 13:56:18 2009 (r196781) +++ stable/7/sys/kern/kern_conf.c Thu Sep 3 14:23:50 2009 (r196782) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include static MALLOC_DEFINE(M_DEVT, "cdev", "cdev storage"); @@ -276,6 +277,7 @@ dead_strategy(struct bio *bp) #define dead_dump (dumper_t *)enxio #define dead_kqfilter (d_kqfilter_t *)enxio +#define dead_mmap_single (d_mmap_single_t *)enodev static struct cdevsw dead_cdevsw = { .d_version = D_VERSION, @@ -290,7 +292,8 @@ static struct cdevsw dead_cdevsw = { .d_strategy = dead_strategy, .d_name = "dead", .d_dump = dead_dump, - .d_kqfilter = dead_kqfilter + .d_kqfilter = dead_kqfilter, + .d_mmap_single = dead_mmap_single }; /* Default methods if driver does not specify method */ @@ -302,6 +305,7 @@ static struct cdevsw dead_cdevsw = { #define no_ioctl (d_ioctl_t *)enodev #define no_mmap (d_mmap_t *)enodev #define no_kqfilter (d_kqfilter_t *)enodev +#define no_mmap_single (d_mmap_single_t *)enodev static void no_strategy(struct bio *bp) @@ -481,6 +485,23 @@ giant_mmap(struct cdev *dev, vm_offset_t return (retval); } +static int +giant_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size, + vm_object_t *object, int nprot) +{ + struct cdevsw *dsw; + int retval; + + dsw = dev_refthread(dev); + if (dsw == NULL) + return (ENXIO); + mtx_lock(&Giant); + retval = dsw->d_gianttrick->d_mmap_single(dev, offset, size, object, + nprot); + mtx_unlock(&Giant); + dev_relthread(dev); + return (retval); +} /* * struct cdev * and u_dev_t primitives @@ -616,7 +637,8 @@ prep_cdevsw(struct cdevsw *devsw) return; } - if (devsw->d_version != D_VERSION_01) { + if (devsw->d_version != D_VERSION_01 && + devsw->d_version != D_VERSION_02) { printf( "WARNING: Device driver \"%s\" has wrong version %s\n", devsw->d_name == NULL ? "???" : devsw->d_name, @@ -632,6 +654,8 @@ prep_cdevsw(struct cdevsw *devsw) devsw->d_dump = dead_dump; devsw->d_kqfilter = dead_kqfilter; } + if (devsw->d_version == D_VERSION_01) + devsw->d_mmap_single = NULL; if (devsw->d_flags & D_TTY) { if (devsw->d_ioctl == NULL) devsw->d_ioctl = ttyioctl; @@ -668,6 +692,7 @@ prep_cdevsw(struct cdevsw *devsw) FIXUP(d_mmap, no_mmap, giant_mmap); FIXUP(d_strategy, no_strategy, giant_strategy); FIXUP(d_kqfilter, no_kqfilter, giant_kqfilter); + FIXUP(d_mmap_single, no_mmap_single, giant_mmap_single); if (devsw->d_dump == NULL) devsw->d_dump = no_dump; Modified: stable/7/sys/sys/conf.h ============================================================================== --- stable/7/sys/sys/conf.h Thu Sep 3 13:56:18 2009 (r196781) +++ stable/7/sys/sys/conf.h Thu Sep 3 14:23:50 2009 (r196782) @@ -106,6 +106,7 @@ struct thread; struct uio; struct knote; struct clonedevs; +struct vm_object; struct vnode; /* @@ -139,10 +140,10 @@ typedef int d_poll_t(struct cdev *dev, i typedef int d_kqfilter_t(struct cdev *dev, struct knote *kn); typedef int d_mmap_t(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot); +typedef int d_mmap_single_t(struct cdev *cdev, vm_ooffset_t *offset, + vm_size_t size, struct vm_object **object, int nprot); typedef void d_purge_t(struct cdev *dev); -typedef int d_spare2_t(struct cdev *dev); - typedef int dumper_t( void *priv, /* Private to the driver. */ void *virtual, /* Virtual (mapped) address. */ @@ -177,7 +178,8 @@ typedef int dumper_t( */ #define D_VERSION_00 0x20011966 #define D_VERSION_01 0x17032005 /* Add d_uid,gid,mode & kind */ -#define D_VERSION D_VERSION_01 +#define D_VERSION_02 0x28042009 /* Add d_mmap_single */ +#define D_VERSION D_VERSION_02 /* * Flags used for internal housekeeping @@ -203,7 +205,7 @@ struct cdevsw { dumper_t *d_dump; d_kqfilter_t *d_kqfilter; d_purge_t *d_purge; - d_spare2_t *d_spare2; + d_mmap_single_t *d_mmap_single; uid_t d_uid; gid_t d_gid; mode_t d_mode; Modified: stable/7/sys/vm/vm_mmap.c ============================================================================== --- stable/7/sys/vm/vm_mmap.c Thu Sep 3 13:56:18 2009 (r196781) +++ stable/7/sys/vm/vm_mmap.c Thu Sep 3 14:23:50 2009 (r196782) @@ -116,9 +116,9 @@ vmmapentry_rsrc_init(dummy) } static int vm_mmap_vnode(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *, - int *, struct vnode *, vm_ooffset_t, vm_object_t *); + int *, struct vnode *, vm_ooffset_t *, vm_object_t *); static int vm_mmap_cdev(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *, - int *, struct cdev *, vm_ooffset_t, vm_object_t *); + int *, struct cdev *, vm_ooffset_t *, vm_object_t *); /* * MPSAFE @@ -1132,14 +1132,13 @@ munlock(td, uap) int vm_mmap_vnode(struct thread *td, vm_size_t objsize, vm_prot_t prot, vm_prot_t *maxprotp, int *flagsp, - struct vnode *vp, vm_ooffset_t foff, vm_object_t *objp) + struct vnode *vp, vm_ooffset_t *foffp, vm_object_t *objp) { struct vattr va; - void *handle; vm_object_t obj; + vm_offset_t foff; struct mount *mp; - struct cdevsw *dsw; - int error, flags, type; + int error, flags; int vfslocked; mp = vp->v_mount; @@ -1148,6 +1147,7 @@ vm_mmap_vnode(struct thread *td, vm_size VFS_UNLOCK_GIANT(vfslocked); return (error); } + foff = *foffp; flags = *flagsp; obj = vp->v_object; if (vp->v_type == VREG) { @@ -1163,41 +1163,12 @@ vm_mmap_vnode(struct thread *td, vm_size vp = (struct vnode*)obj->handle; vget(vp, LK_EXCLUSIVE, td); } - type = OBJT_VNODE; - handle = vp; } else if (vp->v_type == VCHR) { - type = OBJT_DEVICE; - handle = vp->v_rdev; - - dsw = dev_refthread(handle); - if (dsw == NULL) { - error = ENXIO; - goto done; - } - if (dsw->d_flags & D_MMAP_ANON) { - dev_relthread(handle); - *maxprotp = VM_PROT_ALL; - *flagsp |= MAP_ANON; - error = 0; - goto done; - } - dev_relthread(handle); - /* - * cdevs does not provide private mappings of any kind. - */ - if ((*maxprotp & VM_PROT_WRITE) == 0 && - (prot & PROT_WRITE) != 0) { - error = EACCES; - goto done; - } - if (flags & (MAP_PRIVATE|MAP_COPY)) { - error = EINVAL; - goto done; - } - /* - * Force device mappings to be shared. - */ - flags |= MAP_SHARED; + error = vm_mmap_cdev(td, objsize, prot, maxprotp, flagsp, + vp->v_rdev, foffp, objp); + if (error == 0) + goto mark_atime; + goto done; } else { error = EINVAL; goto done; @@ -1224,18 +1195,18 @@ vm_mmap_vnode(struct thread *td, vm_size * we do not need to sync it. * Adjust object size to be the size of actual file. */ - if (vp->v_type == VREG) { - objsize = round_page(va.va_size); - if (va.va_nlink == 0) - flags |= MAP_NOSYNC; - } - obj = vm_pager_allocate(type, handle, objsize, prot, foff); + objsize = round_page(va.va_size); + if (va.va_nlink == 0) + flags |= MAP_NOSYNC; + obj = vm_pager_allocate(OBJT_VNODE, vp, objsize, prot, foff); if (obj == NULL) { - error = (type == OBJT_DEVICE ? EINVAL : ENOMEM); + error = ENOMEM; goto done; } *objp = obj; *flagsp = flags; + +mark_atime: vfs_mark_atime(vp, td); done: @@ -1255,11 +1226,11 @@ done: int vm_mmap_cdev(struct thread *td, vm_size_t objsize, vm_prot_t prot, vm_prot_t *maxprotp, int *flagsp, - struct cdev *cdev, vm_ooffset_t foff, vm_object_t *objp) + struct cdev *cdev, vm_ooffset_t *foff, vm_object_t *objp) { vm_object_t obj; struct cdevsw *dsw; - int flags; + int error, flags; flags = *flagsp; @@ -1272,25 +1243,43 @@ vm_mmap_cdev(struct thread *td, vm_size_ *flagsp |= MAP_ANON; return (0); } - dev_relthread(cdev); /* - * cdevs does not provide private mappings of any kind. + * cdevs do not provide private mappings of any kind. */ if ((*maxprotp & VM_PROT_WRITE) == 0 && - (prot & PROT_WRITE) != 0) + (prot & PROT_WRITE) != 0) { + dev_relthread(cdev); return (EACCES); - if (flags & (MAP_PRIVATE|MAP_COPY)) + } + if (flags & (MAP_PRIVATE|MAP_COPY)) { + dev_relthread(cdev); return (EINVAL); + } /* * Force device mappings to be shared. */ flags |= MAP_SHARED; #ifdef MAC_XXX - error = mac_check_cdev_mmap(td->td_ucred, cdev, prot); - if (error != 0) + error = mac_cdev_check_mmap(td->td_ucred, cdev, prot); + if (error != 0) { + dev_relthread(cdev); return (error); + } #endif - obj = vm_pager_allocate(OBJT_DEVICE, cdev, objsize, prot, foff); + /* + * First, try d_mmap_single(). If that is not implemented + * (returns ENODEV), fall back to using the device pager. + * Note that d_mmap_single() must return a reference to the + * object (it needs to bump the reference count of the object + * it returns somehow). + * + * XXX assumes VM_PROT_* == PROT_* + */ + error = dsw->d_mmap_single(cdev, foff, objsize, objp, (int)prot); + dev_relthread(cdev); + if (error != ENODEV) + return (error); + obj = vm_pager_allocate(OBJT_DEVICE, cdev, objsize, prot, *foff); if (obj == NULL) return (EINVAL); *objp = obj; @@ -1356,11 +1345,11 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, switch (handle_type) { case OBJT_DEVICE: error = vm_mmap_cdev(td, size, prot, &maxprot, &flags, - handle, foff, &object); + handle, &foff, &object); break; case OBJT_VNODE: error = vm_mmap_vnode(td, size, prot, &maxprot, &flags, - handle, foff, &object); + handle, &foff, &object); break; case OBJT_DEFAULT: if (handle == NULL) { From owner-svn-src-stable@FreeBSD.ORG Thu Sep 3 18:16:03 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DE81106566B; Thu, 3 Sep 2009 18:16:03 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7ADB08FC17; Thu, 3 Sep 2009 18:16:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n83IG3nh041108; Thu, 3 Sep 2009 18:16:03 GMT (envelope-from brian@svn.freebsd.org) Received: (from brian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n83IG3jB041106; Thu, 3 Sep 2009 18:16:03 GMT (envelope-from brian@svn.freebsd.org) Message-Id: <200909031816.n83IG3jB041106@svn.freebsd.org> From: Brian Somers Date: Thu, 3 Sep 2009 18:16:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196793 - stable/7/usr.sbin/ppp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 18:16:03 -0000 Author: brian Date: Thu Sep 3 18:16:03 2009 New Revision: 196793 URL: http://svn.freebsd.org/changeset/base/196793 Log: MFC r196530: Document that ppp handles pipe(2) descriptors specially in -direct mode. Modified: stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/ppp/ppp.8.m4 Modified: stable/7/usr.sbin/ppp/ppp.8.m4 ============================================================================== --- stable/7/usr.sbin/ppp/ppp.8.m4 Thu Sep 3 17:37:23 2009 (r196792) +++ stable/7/usr.sbin/ppp/ppp.8.m4 Thu Sep 3 18:16:03 2009 (r196793) @@ -27,7 +27,7 @@ changecom(,)dnl .\" .\" $FreeBSD$ .\" -.Dd May 24, 2007 +.Dd August 25, 2009 .Dt PPP 8 .Os .Sh NAME @@ -171,6 +171,17 @@ If callback is configured, will use the .Dq set device information when dialing back. +.Pp +When run in +.Fl direct +mode, +.Nm +will behave slightly differently if descriptor 0 was created by +.Xr pipe 2 . +As pipes are not bi-directional, ppp will redirect all writes to descriptor +1 (standard output), leaving only reads acting on descriptor 0. +No special action is taken if descriptor 0 was created by +.Xr socketpair 2 . .It Fl dedicated This option is designed for machines connected with a dedicated wire. @@ -6070,6 +6081,8 @@ This socket is used to pass links betwee .Xr tcpdump 1 , .Xr telnet 1 , .Xr kldload 2 , +.Xr pipe 2 , +.Xr socketpair 2 , ifdef({LOCALNAT},{},{.Xr libalias 3 , })dnl ifdef({LOCALRAD},{},{.Xr libradius 3 , From owner-svn-src-stable@FreeBSD.ORG Thu Sep 3 23:55:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 982F51065676; Thu, 3 Sep 2009 23:55:07 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 7EECD8FC0C; Thu, 3 Sep 2009 23:55:07 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id 2FB341A3C92; Thu, 3 Sep 2009 16:47:37 -0700 (PDT) Date: Thu, 3 Sep 2009 16:47:37 -0700 From: Alfred Perlstein To: Remko Lodder Message-ID: <20090903234737.GH21946@elvis.mu.org> References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2009 23:55:07 -0000 Since this information is available via "svn log -g" maybe we can fix the commit email script to include that infomation instead? -Alfred * Remko Lodder [090901 23:13] wrote: > On Wed, September 2, 2009 4:12 am, Alfred Perlstein wrote: > > Author: alfred > > Date: Wed Sep 2 02:12:07 2009 > > New Revision: 196746 > > URL: http://svn.freebsd.org/changeset/base/196746 > > > > Log: > > MFC: r196489,196498 > > Critical USB bugfixes for 8.0 > > > > Dear Alfred (and hps!), > > It would be awesome to see something more about this in the commit log. I > needed to look up the specific revisions to see what changed. I always > learned from Warner and people, that including the original commit > message(s) saves a lot of time and makes it clear about what is being > merged. > > Can you help and include a bit more information next time please? > > Thanks alot! > > -- > /"\ Best regards, | remko@FreeBSD.org > \ / Remko Lodder | remko@EFnet > X http://www.evilcoder.org/ | > / \ ASCII Ribbon Campaign | Against HTML Mail and News > -- - Alfred Perlstein .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250 .- FreeBSD committer From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 00:00:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F6DF106566C; Fri, 4 Sep 2009 00:00:07 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 809388FC14; Fri, 4 Sep 2009 00:00:07 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id E84151A3C85; Thu, 3 Sep 2009 16:43:50 -0700 (PDT) Date: Thu, 3 Sep 2009 16:43:50 -0700 From: Alfred Perlstein To: Mark Linimon Message-ID: <20090903234350.GG21946@elvis.mu.org> References: <200909020212.n822C7Il078379@svn.freebsd.org> <20090902094508.GA1964@lonesome.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090902094508.GA1964@lonesome.com> User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 00:00:07 -0000 * Mark Linimon [090902 03:05] wrote: > On Wed, Sep 02, 2009 at 02:12:07AM +0000, Alfred Perlstein wrote: > > MFC: r196489,196498 > > Critical USB bugfixes for 8.0 > > Will this change anything for ports? Don't think so, it's kernel fixes for crashdumps and memory handling. -- - Alfred Perlstein .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250 .- FreeBSD committer From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 04:48:12 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74D2E106566C; Fri, 4 Sep 2009 04:48:12 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4941B8FC12; Fri, 4 Sep 2009 04:48:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n844mC2U054065; Fri, 4 Sep 2009 04:48:12 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n844mCdq054063; Fri, 4 Sep 2009 04:48:12 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200909040448.n844mCdq054063@svn.freebsd.org> From: Alan Cox Date: Fri, 4 Sep 2009 04:48:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196807 - in stable/7/sys: . contrib/pf vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 04:48:12 -0000 Author: alc Date: Fri Sep 4 04:48:12 2009 New Revision: 196807 URL: http://svn.freebsd.org/changeset/base/196807 Log: MFC r190912 Previously, when vm_page_free_toq() was performed on a page belonging to a reservation, unless all of the reservation's pages were free, the reservation was moved to the head of the partially-populated reservations queue, where it would be the next reservation to be broken in case the free page queues were emptied. Now, instead, I am moving it to the tail. Very likely this reservation is in the process of being freed in its entirety, so placing it at the tail of the queue makes it more likely that the underlying physical memory will be returned to the free page queues as one contiguous chunk. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/vm/vm_reserv.c Modified: stable/7/sys/vm/vm_reserv.c ============================================================================== --- stable/7/sys/vm/vm_reserv.c Fri Sep 4 01:44:31 2009 (r196806) +++ stable/7/sys/vm/vm_reserv.c Fri Sep 4 04:48:12 2009 (r196807) @@ -138,8 +138,8 @@ static vm_reserv_t vm_reserv_array; * The partially-populated reservation queue * * This queue enables the fast recovery of an unused cached or free small page - * from a partially-populated reservation. The head of this queue is either - * the least-recently-populated or most-recently-depopulated reservation. + * from a partially-populated reservation. The reservation at the head of + * this queue is the least-recently-changed, partially-populated reservation. * * Access to this queue is synchronized by the free page queue lock. */ @@ -209,7 +209,7 @@ sysctl_vm_reserv_partpopq(SYSCTL_HANDLER /* * Reduces the given reservation's population count. If the population count * becomes zero, the reservation is destroyed. Additionally, moves the - * reservation to the head of the partially-populated reservations queue if the + * reservation to the tail of the partially-populated reservations queue if the * population count is non-zero. * * The free page queue lock must be held. @@ -235,7 +235,7 @@ vm_reserv_depopulate(vm_reserv_t rv) vm_reserv_freed++; } else { rv->inpartpopq = TRUE; - TAILQ_INSERT_HEAD(&vm_rvq_partpop, rv, partpopq); + TAILQ_INSERT_TAIL(&vm_rvq_partpop, rv, partpopq); } } From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 05:06:15 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 693B6106566B; Fri, 4 Sep 2009 05:06:15 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 57C978FC14; Fri, 4 Sep 2009 05:06:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8456FnX054464; Fri, 4 Sep 2009 05:06:15 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8456FjI054462; Fri, 4 Sep 2009 05:06:15 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200909040506.n8456FjI054462@svn.freebsd.org> From: Alan Cox Date: Fri, 4 Sep 2009 05:06:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196808 - in stable/7/sys: . amd64/include contrib/pf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 05:06:15 -0000 Author: alc Date: Fri Sep 4 05:06:15 2009 New Revision: 196808 URL: http://svn.freebsd.org/changeset/base/196808 Log: MFC r193729 Now that amd64's kernel map is 512GB (r192469), there is no reason to cap its buffer map at 400MB. Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/include/param.h stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/amd64/include/param.h ============================================================================== --- stable/7/sys/amd64/include/param.h Fri Sep 4 04:48:12 2009 (r196807) +++ stable/7/sys/amd64/include/param.h Fri Sep 4 05:06:15 2009 (r196808) @@ -131,15 +131,6 @@ #endif /* - * Ceiling on size of buffer cache (really only effects write queueing, - * the VM page cache is not effected), can be changed via - * the kern.maxbcache /boot/loader.conf variable. - */ -#ifndef VM_BCACHE_SIZE_MAX -#define VM_BCACHE_SIZE_MAX (400 * 1024 * 1024) -#endif - -/* * Mach derived conversion macros */ #define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 05:37:50 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94E4C1065692; Fri, 4 Sep 2009 05:37:50 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 812AB8FC0A; Fri, 4 Sep 2009 05:37:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n845boBE055242; Fri, 4 Sep 2009 05:37:50 GMT (envelope-from weongyo@svn.freebsd.org) Received: (from weongyo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n845boWQ055241; Fri, 4 Sep 2009 05:37:50 GMT (envelope-from weongyo@svn.freebsd.org) Message-Id: <200909040537.n845boWQ055241@svn.freebsd.org> From: Weongyo Jeong Date: Fri, 4 Sep 2009 05:37:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196810 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb/wlan dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 05:37:50 -0000 Author: weongyo Date: Fri Sep 4 05:37:49 2009 New Revision: 196810 URL: http://svn.freebsd.org/changeset/base/196810 Log: MFC r196809: fix a TX issue on big endian machines like powerpc or sparc64. Now zyd(4) should work on all architectures. Obtained from: OpenBSD Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/usb/wlan/if_zyd.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/wlan/if_zyd.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_zyd.c Fri Sep 4 05:28:09 2009 (r196809) +++ stable/8/sys/dev/usb/wlan/if_zyd.c Fri Sep 4 05:37:49 2009 (r196810) @@ -2547,7 +2547,7 @@ zyd_tx_start(struct zyd_softc *sc, struc bits = (rate == 11) ? (totlen * 16) + 10 : ((rate == 22) ? (totlen * 8) + 10 : (totlen * 8)); - desc->plcp_length = bits / ratediv[phy]; + desc->plcp_length = htole16(bits / ratediv[phy]); desc->plcp_service = 0; if (rate == 22 && (bits % 11) > 0 && (bits % 11) <= 3) desc->plcp_service |= ZYD_PLCP_LENGEXT; From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 06:37:45 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 785171065693; Fri, 4 Sep 2009 06:37:45 +0000 (UTC) (envelope-from remko@elvandar.org) Received: from websrv01.jr-hosting.nl (websrv01.jr-hosting.nl [78.47.69.233]) by mx1.freebsd.org (Postfix) with ESMTP id 33D2C8FC08; Fri, 4 Sep 2009 06:37:45 +0000 (UTC) Received: from a83-163-38-147.adsl.xs4all.nl ([83.163.38.147] helo=[10.0.2.66]) by websrv01.jr-hosting.nl with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69 (FreeBSD)) (envelope-from ) id 1MjSQZ-0000qL-O9; Fri, 04 Sep 2009 08:37:43 +0200 Message-Id: <9D3CE1CC-74A7-4913-857E-7BBC7E44A379@elvandar.org> From: Remko Lodder To: Alfred Perlstein In-Reply-To: <20090903234737.GH21946@elvis.mu.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Date: Fri, 4 Sep 2009 08:37:42 +0200 References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <20090903234737.GH21946@elvis.mu.org> X-Mailer: Apple Mail (2.936) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 06:37:45 -0000 On Sep 4, 2009, at 1:47 AM, Alfred Perlstein wrote: > Since this information is available via "svn log -g" > maybe we can fix the commit email script to include that > infomation instead? > > -Alfred > > Hey Alfred, I do not mind very much how the information gets there, but I find it very comfortable if it's there (it saves me a lot of time, and I can keep up with the project like this) thanks for thinking along! -- /"\ Best regards, | remko@FreeBSD.org \ / Remko Lodder | remko@EFnet X http://www.evilcoder.org/ | / \ ASCII Ribbon Campaign | Against HTML Mail and News From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 07:13:08 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5674D1065670; Fri, 4 Sep 2009 07:13:08 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B4B48FC08; Fri, 4 Sep 2009 07:13:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n847D8J1057562; Fri, 4 Sep 2009 07:13:08 GMT (envelope-from julian@svn.freebsd.org) Received: (from julian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n847D7if057561; Fri, 4 Sep 2009 07:13:07 GMT (envelope-from julian@svn.freebsd.org) Message-Id: <200909040713.n847D7if057561@svn.freebsd.org> From: Julian Elischer Date: Fri, 4 Sep 2009 07:13:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196815 - stable/8/share/man/man9 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 07:13:08 -0000 Author: julian Date: Fri Sep 4 07:13:07 2009 New Revision: 196815 URL: http://svn.freebsd.org/changeset/base/196815 Log: MFC r196450 Add clarifications to the kproc and kthread manpages and link the kthread_create(9) man page to the kproc(9) page as it has migrated and people looking for it may need a hand to find its new name. Approved by: re (kib) Modified: stable/8/share/man/man9/ (props changed) stable/8/share/man/man9/Makefile stable/8/share/man/man9/kproc.9 stable/8/share/man/man9/kthread.9 Modified: stable/8/share/man/man9/Makefile ============================================================================== --- stable/8/share/man/man9/Makefile Fri Sep 4 06:26:40 2009 (r196814) +++ stable/8/share/man/man9/Makefile Fri Sep 4 07:13:07 2009 (r196815) @@ -713,6 +713,7 @@ MLINKS+=kobj.9 DEFINE_CLASS.9 \ kobj.9 kobj_delete.9 \ kobj.9 kobj_init.9 MLINKS+=kproc.9 kproc_create.9 \ + kproc.9 kthread_create.9 \ kproc.9 kproc_exit.9 \ kproc.9 kproc_resume.9 \ kproc.9 kproc_shutdown.9 \ Modified: stable/8/share/man/man9/kproc.9 ============================================================================== --- stable/8/share/man/man9/kproc.9 Fri Sep 4 06:26:40 2009 (r196814) +++ stable/8/share/man/man9/kproc.9 Fri Sep 4 07:13:07 2009 (r196815) @@ -64,6 +64,28 @@ .Fa "int flags" "int pages" "char * procname" "const char *fmt" "..." .Fc .Sh DESCRIPTION +In +.Fx 8.0 , +the +.Fn kthread* 9 +family of functions was renamed to be the +.Fn kproc* 9 +family of functions, as they were misnamed +and actually produced kernel processes. +A new family of +.Em different +.Fn kthread_* 9 +functions was added to produce +.Em real +kernel +.Em threads . +See the +.Xr kthread 9 +man page for more information on those calls. +Also note that the +.Fn kproc_kthread_add 9 +function appears in both pages as its functionality is split. +.Pp The function .Fn kproc_start is used to start Modified: stable/8/share/man/man9/kthread.9 ============================================================================== --- stable/8/share/man/man9/kthread.9 Fri Sep 4 06:26:40 2009 (r196814) +++ stable/8/share/man/man9/kthread.9 Fri Sep 4 07:13:07 2009 (r196815) @@ -65,6 +65,27 @@ .Fa "int flags" "int pages" "char * procname" "const char *fmt" "..." .Fc .Sh DESCRIPTION +In +.Fx 8.0 , +the older family of +.Fn kthread_* 9 +functions was renamed to be the +.Fn kproc_* 9 +family of functions, +as they were previously misnamed +and actually produced kernel processes. +This new family of +.Fn kthread_* 9 +functions was added to produce +.Em real +kernel threads. +See the +.Xr kproc 9 +man page for more information on the renamed calls. +Also note that the +.Fn kproc_kthread_add 9 +function appears in both pages as its functionality is split. +.Pp The function .Fn kthread_start is used to start From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 07:53:50 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 087111065693; Fri, 4 Sep 2009 07:53:50 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 82D838FC08; Fri, 4 Sep 2009 07:53:49 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 6EA536D41B; Fri, 4 Sep 2009 07:53:48 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 4F6F5844B4; Fri, 4 Sep 2009 09:53:48 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Alfred Perlstein References: <200909020212.n822C7Il078379@svn.freebsd.org> <8497dc1520e5fe6b2b3727d5fb92f358.squirrel@www.jr-hosting.nl> <20090903234737.GH21946@elvis.mu.org> Date: Fri, 04 Sep 2009 09:53:47 +0200 In-Reply-To: <20090903234737.GH21946@elvis.mu.org> (Alfred Perlstein's message of "Thu, 3 Sep 2009 16:47:37 -0700") Message-ID: <86d467jgc4.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, Remko Lodder , src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r196746 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/usb/input dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 07:53:50 -0000 Alfred Perlstein writes: > Since this information is available via "svn log -g" maybe we can fix > the commit email script to include that infomation instead? Because some people like to use "svn log" from time to time. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 11:32:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBB37106566B; Fri, 4 Sep 2009 11:32:05 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C909F8FC20; Fri, 4 Sep 2009 11:32:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n84BW51l065618; Fri, 4 Sep 2009 11:32:05 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n84BW5H5065617; Fri, 4 Sep 2009 11:32:05 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200909041132.n84BW5H5065617@svn.freebsd.org> From: Stanislav Sedov Date: Fri, 4 Sep 2009 11:32:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196828 - in stable/8/sys: . amd64/include/xen cam/scsi cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 11:32:06 -0000 Author: stas Date: Fri Sep 4 11:32:05 2009 New Revision: 196828 URL: http://svn.freebsd.org/changeset/base/196828 Log: - MFC r196568: - Add quirk for Sony DSC digital cameras. This umass devices fail to attach without these quirks applied. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cam/scsi/scsi_da.c stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/8/sys/cam/scsi/scsi_da.c Fri Sep 4 10:22:29 2009 (r196827) +++ stable/8/sys/cam/scsi/scsi_da.c Fri Sep 4 11:32:05 2009 (r196828) @@ -554,6 +554,14 @@ static struct da_quirk_entry da_quirk_ta { {T_DIRECT, SIP_MEDIA_REMOVABLE, "Netac", "OnlyDisk*", "2000"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, + { + /* + * Sony Cyber-Shot DSC cameras + * PR: usb/137035 + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "Sony", "Sony DSC", "*"}, + /*quirks*/ DA_Q_NO_SYNC_CACHE | DA_Q_NO_PREVENT } }; From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 16:41:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A25E1065679; Fri, 4 Sep 2009 16:41:18 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D5FC8FC0C; Fri, 4 Sep 2009 16:41:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n84GfIbC084444; Fri, 4 Sep 2009 16:41:18 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n84GfIME084442; Fri, 4 Sep 2009 16:41:18 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200909041641.n84GfIME084442@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 4 Sep 2009 16:41:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196830 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/txp dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 16:41:18 -0000 Author: yongari Date: Fri Sep 4 16:41:17 2009 New Revision: 196830 URL: http://svn.freebsd.org/changeset/base/196830 Log: MFC r196721: Make sure rx descriptor ring align on 16 bytes. I guess the alignment requirement could be multiple of 4 bytes but I think using descriptor size would make intention clearer. Previously the size of rx descriptor was not power of 2 so it caused panic in bus_dmamem_alloc(9). Reported by: Jeff Blank (jb000003 <> mr-happy dot com) Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/txp/if_txp.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/txp/if_txp.c ============================================================================== --- stable/8/sys/dev/txp/if_txp.c Fri Sep 4 14:53:12 2009 (r196829) +++ stable/8/sys/dev/txp/if_txp.c Fri Sep 4 16:41:17 2009 (r196830) @@ -1389,7 +1389,8 @@ txp_alloc_rings(struct txp_softc *sc) /* High priority rx ring. */ error = txp_dma_alloc(sc, "hi priority rx ring", - &sc->sc_cdata.txp_rxhiring_tag, sizeof(struct txp_rx_desc), 0, + &sc->sc_cdata.txp_rxhiring_tag, + roundup(sizeof(struct txp_rx_desc), 16), 0, &sc->sc_cdata.txp_rxhiring_map, (void **)&sc->sc_ldata.txp_rxhiring, sizeof(struct txp_rx_desc) * RX_ENTRIES, &sc->sc_ldata.txp_rxhiring_paddr); @@ -1409,7 +1410,8 @@ txp_alloc_rings(struct txp_softc *sc) /* Low priority rx ring. */ error = txp_dma_alloc(sc, "low priority rx ring", - &sc->sc_cdata.txp_rxloring_tag, sizeof(struct txp_rx_desc), 0, + &sc->sc_cdata.txp_rxloring_tag, + roundup(sizeof(struct txp_rx_desc), 16), 0, &sc->sc_cdata.txp_rxloring_map, (void **)&sc->sc_ldata.txp_rxloring, sizeof(struct txp_rx_desc) * RX_ENTRIES, &sc->sc_ldata.txp_rxloring_paddr); From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 19:59:33 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 383CD106566C; Fri, 4 Sep 2009 19:59:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2286C8FC13; Fri, 4 Sep 2009 19:59:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n84JxXcn009878; Fri, 4 Sep 2009 19:59:33 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n84JxWGA009848; Fri, 4 Sep 2009 19:59:32 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200909041959.n84JxWGA009848@svn.freebsd.org> From: John Baldwin Date: Fri, 4 Sep 2009 19:59:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196838 - in stable/7/sys: . amd64/amd64 amd64/include arm/include contrib/pf dev/iir i386/i386 i386/include ia64/include kern powerpc/include sparc64/include sun4v/include sun4v/sun4v vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 19:59:33 -0000 Author: jhb Date: Fri Sep 4 19:59:32 2009 New Revision: 196838 URL: http://svn.freebsd.org/changeset/base/196838 Log: MFC 193396, 193521, 194331, 194337, 194376, 194454, 194562, 194642, 195033, 195385, 195649, 195660, 195749, and 195774: Add support to the virtual memory system for configuring machine- dependent memory attributes: - Refactor contigmalloc() into two functions: a simple front-end that deals with the malloc tag and calls a new back-end, kmem_alloc_contig(), that allocates the pages and maps them. - Use kmem_alloc_contig() to implement the UMA back-end allocator for jumbo frame zones. - Use kmem_alloc_contig() to allocate the top-level page tables for PAE. - Introduce vm_memattr_t to as a type to hold memory attributes. - Introduce vm_object_set_memattr() for setting the default memory attributes that will be given to an object's pages. - Introduce and use pmap_page_{get,set}_memattr() for getting and setting a page's machine-dependent memory attributes. Add full support for these functions on amd64 and i386 and stubs for them on the other architectures. The function pmap_page_set_memattr() is also responsible for any other machine-dependent aspects of changing a page's memory attributes, such as flushing the cache or updating the direct map. The uses include kmem_alloc_contig(), vm_page_alloc(), and the device pager: kmem_alloc_contig() can now be used to allocate kernel memory with non-default memory attributes on amd64 and i386. vm_page_alloc() and the device pager will set the memory attributes for the real or fictitious page according to the object's default memory attributes. - Update the various pmap functions on amd64 and i386 that map pages to incorporate each page's memory attributes in the mapping. Reviewed by: alc Added: stable/7/sys/amd64/include/vm.h - copied, changed from r195033, head/sys/amd64/include/vm.h stable/7/sys/arm/include/vm.h - copied, changed from r195033, head/sys/arm/include/vm.h stable/7/sys/i386/include/vm.h - copied, changed from r195033, head/sys/i386/include/vm.h stable/7/sys/ia64/include/vm.h - copied, changed from r195033, head/sys/ia64/include/vm.h stable/7/sys/powerpc/include/vm.h - copied, changed from r195033, head/sys/powerpc/include/vm.h stable/7/sys/sparc64/include/vm.h - copied, changed from r195033, head/sys/sparc64/include/vm.h stable/7/sys/sun4v/include/vm.h - copied, changed from r195033, head/sys/sun4v/include/vm.h Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/amd64/pmap.c stable/7/sys/amd64/include/pmap.h stable/7/sys/arm/include/pmap.h stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/iir/iir.c stable/7/sys/dev/iir/iir_ctrl.c stable/7/sys/i386/i386/pmap.c stable/7/sys/i386/include/pmap.h stable/7/sys/ia64/include/pmap.h stable/7/sys/kern/kern_mbuf.c stable/7/sys/powerpc/include/pmap.h stable/7/sys/sparc64/include/pmap.h stable/7/sys/sun4v/include/pmap.h stable/7/sys/sun4v/sun4v/pmap.c stable/7/sys/vm/device_pager.c stable/7/sys/vm/pmap.h stable/7/sys/vm/vm.h stable/7/sys/vm/vm_contig.c stable/7/sys/vm/vm_extern.h stable/7/sys/vm/vm_object.c stable/7/sys/vm/vm_object.h stable/7/sys/vm/vm_page.c stable/7/sys/vm/vm_phys.c Modified: stable/7/sys/amd64/amd64/pmap.c ============================================================================== --- stable/7/sys/amd64/amd64/pmap.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/amd64/amd64/pmap.c Fri Sep 4 19:59:32 2009 (r196838) @@ -618,6 +618,7 @@ pmap_page_init(vm_page_t m) { TAILQ_INIT(&m->md.pv_list); + m->md.pat_mode = PAT_WRITE_BACK; } /* @@ -748,21 +749,6 @@ pmap_cache_bits(int mode, boolean_t is_p /* The PAT bit is different for PTE's and PDE's. */ pat_flag = is_pde ? PG_PDE_PAT : PG_PTE_PAT; - /* If we don't support PAT, map extended modes to older ones. */ - if (!(cpu_feature & CPUID_PAT)) { - switch (mode) { - case PAT_UNCACHEABLE: - case PAT_WRITE_THROUGH: - case PAT_WRITE_BACK: - break; - case PAT_UNCACHED: - case PAT_WRITE_COMBINING: - case PAT_WRITE_PROTECTED: - mode = PAT_UNCACHEABLE; - break; - } - } - /* Map the caching mode to a PAT index. */ switch (mode) { #ifdef PAT_WORKS @@ -1134,7 +1120,8 @@ pmap_qenter(vm_offset_t sva, vm_page_t * endpte = pte + count; while (pte < endpte) { oldpte |= *pte; - pte_store(pte, VM_PAGE_TO_PHYS(*ma) | PG_G | PG_RW | PG_V); + pte_store(pte, VM_PAGE_TO_PHYS(*ma) | PG_G | + pmap_cache_bits((*ma)->md.pat_mode, 0) | PG_RW | PG_V); pte++; ma++; } @@ -3046,7 +3033,7 @@ validate: /* * Now validate mapping with desired protection/wiring. */ - newpte = (pt_entry_t)(pa | PG_V); + newpte = (pt_entry_t)(pa | pmap_cache_bits(m->md.pat_mode, 0) | PG_V); if ((prot & VM_PROT_WRITE) != 0) { newpte |= PG_RW; vm_page_flag_set(m, PG_WRITEABLE); @@ -3131,7 +3118,8 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t " in pmap %p", va, pmap); return (FALSE); } - newpde = VM_PAGE_TO_PHYS(m) | PG_PS | PG_V; + newpde = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(m->md.pat_mode, 1) | + PG_PS | PG_V; if ((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0) { newpde |= PG_MANAGED; @@ -3318,7 +3306,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_ */ pmap->pm_stats.resident_count++; - pa = VM_PAGE_TO_PHYS(m); + pa = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(m->md.pat_mode, 0); if ((prot & VM_PROT_EXECUTE) == 0) pa |= pg_nx; @@ -3359,6 +3347,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs pd_entry_t *pde; vm_paddr_t pa, ptepa; vm_page_t p, pdpg; + int pat_mode; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); KASSERT(object->type == OBJT_DEVICE, @@ -3369,6 +3358,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs p = vm_page_lookup(object, pindex); KASSERT(p->valid == VM_PAGE_BITS_ALL, ("pmap_object_init_pt: invalid page %p", p)); + pat_mode = p->md.pat_mode; /* * Abort the mapping if the first page is not physically @@ -3380,21 +3370,28 @@ pmap_object_init_pt(pmap_t pmap, vm_offs /* * Skip the first page. Abort the mapping if the rest of - * the pages are not physically contiguous. + * the pages are not physically contiguous or have differing + * memory attributes. */ p = TAILQ_NEXT(p, listq); for (pa = ptepa + PAGE_SIZE; pa < ptepa + size; pa += PAGE_SIZE) { KASSERT(p->valid == VM_PAGE_BITS_ALL, ("pmap_object_init_pt: invalid page %p", p)); - if (pa != VM_PAGE_TO_PHYS(p)) + if (pa != VM_PAGE_TO_PHYS(p) || + pat_mode != p->md.pat_mode) return; p = TAILQ_NEXT(p, listq); } - /* Map using 2MB pages. */ + /* + * Map using 2MB pages. Since "ptepa" is 2M aligned and + * "size" is a multiple of 2M, adding the PAT setting to "pa" + * will not affect the termination of this loop. + */ PMAP_LOCK(pmap); - for (pa = ptepa; pa < ptepa + size; pa += NBPDR) { + for (pa = ptepa | pmap_cache_bits(pat_mode, 1); pa < ptepa + + size; pa += NBPDR) { pdpg = pmap_allocpde(pmap, addr, M_NOWAIT); if (pdpg == NULL) { /* @@ -4305,6 +4302,26 @@ pmap_unmapdev(vm_offset_t va, vm_size_t } /* + * Sets the memory attribute for the specified page. + */ +void +pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma) +{ + + m->md.pat_mode = ma; + + /* + * If "m" is a normal page, update its direct mapping. This update + * can be relied upon to perform any cache operations that are + * required for data coherence. + */ + if ((m->flags & PG_FICTITIOUS) == 0 && + pmap_change_attr(PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)), PAGE_SIZE, + m->md.pat_mode)) + panic("memory attribute change on the direct map failed"); +} + +/* * Changes the specified virtual address range's memory type to that given by * the parameter "mode". The specified virtual address range must be * completely contained within either the direct map or the kernel map. If Modified: stable/7/sys/amd64/include/pmap.h ============================================================================== --- stable/7/sys/amd64/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/amd64/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -234,7 +234,7 @@ struct pv_entry; struct pv_chunk; struct md_page { - int pv_unused; + int pat_mode; TAILQ_HEAD(,pv_entry) pv_list; }; @@ -306,6 +306,7 @@ extern vm_paddr_t dump_avail[]; extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; +#define pmap_page_get_memattr(m) ((vm_memattr_t)(m)->md.pat_mode) #define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz)) void pmap_bootstrap(vm_paddr_t *); @@ -319,6 +320,7 @@ void *pmap_mapbios(vm_paddr_t, vm_size_t void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int); boolean_t pmap_page_is_mapped(vm_page_t m); +void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); void pmap_unmapdev(vm_offset_t, vm_size_t); void pmap_invalidate_page(pmap_t, vm_offset_t); void pmap_invalidate_range(pmap_t, vm_offset_t, vm_offset_t); Copied and modified: stable/7/sys/amd64/include/vm.h (from r195033, head/sys/amd64/include/vm.h) ============================================================================== --- head/sys/amd64/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/amd64/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -32,14 +32,14 @@ #include -/* Cache control options. */ -#define VM_CACHE_UNCACHEABLE ((vm_cache_mode_t)PAT_UNCACHEABLE) -#define VM_CACHE_WRITE_COMBINING ((vm_cache_mode_t)PAT_WRITE_COMBINING) -#define VM_CACHE_WRITE_THROUGH ((vm_cache_mode_t)PAT_WRITE_THROUGH) -#define VM_CACHE_WRITE_PROTECTED ((vm_cache_mode_t)PAT_WRITE_PROTECTED) -#define VM_CACHE_WRITE_BACK ((vm_cache_mode_t)PAT_WRITE_BACK) -#define VM_CACHE_UNCACHED ((vm_cache_mode_t)PAT_UNCACHED) +/* Memory attributes. */ +#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE) +#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING) +#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH) +#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED) +#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK) +#define VM_MEMATTR_UNCACHED ((vm_memattr_t)PAT_UNCACHED) -#define VM_CACHE_DEFAULT VM_CACHE_WRITE_BACK +#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/arm/include/pmap.h ============================================================================== --- stable/7/sys/arm/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/arm/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -75,7 +75,10 @@ #endif +#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) +#define pmap_page_set_memattr(m, ma) (void)0 + /* * Pmap stuff */ Copied and modified: stable/7/sys/arm/include/vm.h (from r195033, head/sys/arm/include/vm.h) ============================================================================== --- head/sys/arm/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/arm/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -29,7 +29,7 @@ #ifndef _MACHINE_VM_H_ #define _MACHINE_VM_H_ -/* Cache control is not (yet) implemented. */ -#define VM_CACHE_DEFAULT 0 +/* Memory attribute configuration is not (yet) implemented. */ +#define VM_MEMATTR_DEFAULT 0 #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/dev/iir/iir.c ============================================================================== --- stable/7/sys/dev/iir/iir.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/dev/iir/iir.c Fri Sep 4 19:59:32 2009 (r196838) @@ -67,9 +67,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include - #include MALLOC_DEFINE(M_GDTBUF, "iirbuf", "iir driver buffer"); Modified: stable/7/sys/dev/iir/iir_ctrl.c ============================================================================== --- stable/7/sys/dev/iir/iir_ctrl.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/dev/iir/iir_ctrl.c Fri Sep 4 19:59:32 2009 (r196838) @@ -52,10 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include -#include -#include #include Modified: stable/7/sys/i386/i386/pmap.c ============================================================================== --- stable/7/sys/i386/i386/pmap.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/i386/i386/pmap.c Fri Sep 4 19:59:32 2009 (r196838) @@ -556,20 +556,18 @@ pmap_page_init(vm_page_t m) { TAILQ_INIT(&m->md.pv_list); + m->md.pat_mode = PAT_WRITE_BACK; } #ifdef PAE - -static MALLOC_DEFINE(M_PMAPPDPT, "pmap", "pmap pdpt"); - static void * pmap_pdpt_allocf(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) { /* Inform UMA that this allocator uses kernel_map/object. */ *flags = UMA_SLAB_KERNEL; - return (contigmalloc(PAGE_SIZE, M_PMAPPDPT, 0, 0x0ULL, 0xffffffffULL, - 1, 0)); + return ((void *)kmem_alloc_contig(kernel_map, bytes, wait, 0x0ULL, + 0xffffffffULL, 1, 0, VM_MEMATTR_DEFAULT)); } #endif @@ -1206,7 +1204,8 @@ pmap_qenter(vm_offset_t sva, vm_page_t * endpte = pte + count; while (pte < endpte) { oldpte |= *pte; - pte_store(pte, VM_PAGE_TO_PHYS(*ma) | pgeflag | PG_RW | PG_V); + pte_store(pte, VM_PAGE_TO_PHYS(*ma) | pgeflag | + pmap_cache_bits((*ma)->md.pat_mode, 0) | PG_RW | PG_V); pte++; ma++; } @@ -3161,7 +3160,7 @@ validate: /* * Now validate mapping with desired protection/wiring. */ - newpte = (pt_entry_t)(pa | PG_V); + newpte = (pt_entry_t)(pa | pmap_cache_bits(m->md.pat_mode, 0) | PG_V); if ((prot & VM_PROT_WRITE) != 0) { newpte |= PG_RW; vm_page_flag_set(m, PG_WRITEABLE); @@ -3243,7 +3242,8 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t " in pmap %p", va, pmap); return (FALSE); } - newpde = VM_PAGE_TO_PHYS(m) | PG_PS | PG_V; + newpde = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(m->md.pat_mode, 1) | + PG_PS | PG_V; if ((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0) { newpde |= PG_MANAGED; @@ -3428,7 +3428,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_ */ pmap->pm_stats.resident_count++; - pa = VM_PAGE_TO_PHYS(m); + pa = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(m->md.pat_mode, 0); #ifdef PAE if ((prot & VM_PROT_EXECUTE) == 0) pa |= pg_nx; @@ -3471,6 +3471,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs pd_entry_t *pde; vm_paddr_t pa, ptepa; vm_page_t p; + int pat_mode; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); KASSERT(object->type == OBJT_DEVICE, @@ -3482,6 +3483,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs p = vm_page_lookup(object, pindex); KASSERT(p->valid == VM_PAGE_BITS_ALL, ("pmap_object_init_pt: invalid page %p", p)); + pat_mode = p->md.pat_mode; /* * Abort the mapping if the first page is not physically @@ -3493,21 +3495,28 @@ pmap_object_init_pt(pmap_t pmap, vm_offs /* * Skip the first page. Abort the mapping if the rest of - * the pages are not physically contiguous. + * the pages are not physically contiguous or have differing + * memory attributes. */ p = TAILQ_NEXT(p, listq); for (pa = ptepa + PAGE_SIZE; pa < ptepa + size; pa += PAGE_SIZE) { KASSERT(p->valid == VM_PAGE_BITS_ALL, ("pmap_object_init_pt: invalid page %p", p)); - if (pa != VM_PAGE_TO_PHYS(p)) + if (pa != VM_PAGE_TO_PHYS(p) || + pat_mode != p->md.pat_mode) return; p = TAILQ_NEXT(p, listq); } - /* Map using 2/4MB pages. */ + /* + * Map using 2/4MB pages. Since "ptepa" is 2/4M aligned and + * "size" is a multiple of 2/4M, adding the PAT setting to + * "pa" will not affect the termination of this loop. + */ PMAP_LOCK(pmap); - for (pa = ptepa; pa < ptepa + size; pa += NBPDR) { + for (pa = ptepa | pmap_cache_bits(pat_mode, 1); pa < ptepa + + size; pa += NBPDR) { pde = pmap_pde(pmap, addr); if (*pde == 0) { pde_store(pde, pa | PG_PS | PG_M | PG_A | @@ -3723,7 +3732,8 @@ pmap_zero_page(vm_page_t m) if (*sysmaps->CMAP2) panic("pmap_zero_page: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M; + *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pmap_cache_bits(m->md.pat_mode, 0); invlcaddr(sysmaps->CADDR2); pagezero(sysmaps->CADDR2); *sysmaps->CMAP2 = 0; @@ -3745,9 +3755,10 @@ pmap_zero_page_area(vm_page_t m, int off sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)]; mtx_lock(&sysmaps->lock); if (*sysmaps->CMAP2) - panic("pmap_zero_page: CMAP2 busy"); + panic("pmap_zero_page_area: CMAP2 busy"); sched_pin(); - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M; + *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pmap_cache_bits(m->md.pat_mode, 0); invlcaddr(sysmaps->CADDR2); if (off == 0 && size == PAGE_SIZE) pagezero(sysmaps->CADDR2); @@ -3769,9 +3780,10 @@ pmap_zero_page_idle(vm_page_t m) { if (*CMAP3) - panic("pmap_zero_page: CMAP3 busy"); + panic("pmap_zero_page_idle: CMAP3 busy"); sched_pin(); - *CMAP3 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M; + *CMAP3 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | + pmap_cache_bits(m->md.pat_mode, 0); invlcaddr(CADDR3); pagezero(CADDR3); *CMAP3 = 0; @@ -3798,8 +3810,10 @@ pmap_copy_page(vm_page_t src, vm_page_t sched_pin(); invlpg((u_int)sysmaps->CADDR1); invlpg((u_int)sysmaps->CADDR2); - *sysmaps->CMAP1 = PG_V | VM_PAGE_TO_PHYS(src) | PG_A; - *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(dst) | PG_A | PG_M; + *sysmaps->CMAP1 = PG_V | VM_PAGE_TO_PHYS(src) | PG_A | + pmap_cache_bits(src->md.pat_mode, 0); + *sysmaps->CMAP2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(dst) | PG_A | PG_M | + pmap_cache_bits(dst->md.pat_mode, 0); bcopy(sysmaps->CADDR1, sysmaps->CADDR2, PAGE_SIZE); *sysmaps->CMAP1 = 0; *sysmaps->CMAP2 = 0; @@ -4420,7 +4434,9 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_ pa += PAGE_SIZE; } pmap_invalidate_range(kernel_pmap, va, tmpva); - pmap_invalidate_cache(); + /* If "Self Snoop" is supported, do nothing. */ + if (!(cpu_feature & CPUID_SS)) + pmap_invalidate_cache(); return ((void *)(va + offset)); } @@ -4455,6 +4471,25 @@ pmap_unmapdev(vm_offset_t va, vm_size_t } /* + * Sets the memory attribute for the specified page. + */ +void +pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma) +{ + + m->md.pat_mode = ma; + + /* + * If "m" is a normal page, flush it from the cache. + */ + if ((m->flags & PG_FICTITIOUS) == 0) { + /* If "Self Snoop" is supported, do nothing. */ + if (!(cpu_feature & CPUID_SS)) + pmap_invalidate_cache(); + } +} + +/* * Changes the specified virtual address range's memory type to that given by * the parameter "mode". The specified virtual address range must be * completely contained within either the kernel map. Modified: stable/7/sys/i386/include/pmap.h ============================================================================== --- stable/7/sys/i386/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/i386/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -332,7 +332,7 @@ struct pv_entry; struct pv_chunk; struct md_page { - int pv_unused; + int pat_mode; TAILQ_HEAD(,pv_entry) pv_list; }; @@ -411,6 +411,7 @@ extern char *ptvmmap; /* poor name! */ extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; +#define pmap_page_get_memattr(m) ((vm_memattr_t)(m)->md.pat_mode) #define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz)) void pmap_bootstrap(vm_paddr_t); @@ -423,6 +424,7 @@ void *pmap_mapbios(vm_paddr_t, vm_size_t void *pmap_mapdev(vm_paddr_t, vm_size_t); void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, int); boolean_t pmap_page_is_mapped(vm_page_t m); +void pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma); void pmap_unmapdev(vm_offset_t, vm_size_t); pt_entry_t *pmap_pte(pmap_t, vm_offset_t) __pure2; void pmap_set_pg(void); Copied and modified: stable/7/sys/i386/include/vm.h (from r195033, head/sys/i386/include/vm.h) ============================================================================== --- head/sys/i386/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/i386/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -32,14 +32,14 @@ #include -/* Cache control options. */ -#define VM_CACHE_UNCACHEABLE ((vm_cache_mode_t)PAT_UNCACHEABLE) -#define VM_CACHE_WRITE_COMBINING ((vm_cache_mode_t)PAT_WRITE_COMBINING) -#define VM_CACHE_WRITE_THROUGH ((vm_cache_mode_t)PAT_WRITE_THROUGH) -#define VM_CACHE_WRITE_PROTECTED ((vm_cache_mode_t)PAT_WRITE_PROTECTED) -#define VM_CACHE_WRITE_BACK ((vm_cache_mode_t)PAT_WRITE_BACK) -#define VM_CACHE_UNCACHED ((vm_cache_mode_t)PAT_UNCACHED) +/* Memory attributes. */ +#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PAT_UNCACHEABLE) +#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PAT_WRITE_COMBINING) +#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PAT_WRITE_THROUGH) +#define VM_MEMATTR_WRITE_PROTECTED ((vm_memattr_t)PAT_WRITE_PROTECTED) +#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PAT_WRITE_BACK) +#define VM_MEMATTR_UNCACHED ((vm_memattr_t)PAT_UNCACHED) -#define VM_CACHE_DEFAULT VM_CACHE_WRITE_BACK +#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/ia64/include/pmap.h ============================================================================== --- stable/7/sys/ia64/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/ia64/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -118,7 +118,9 @@ extern vm_offset_t virtual_end; extern uint64_t pmap_vhpt_base[]; extern int pmap_vhpt_log2size; +#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) +#define pmap_page_set_memattr(m, ma) (void)0 #define pmap_mapbios(pa, sz) pmap_mapdev(pa, sz) #define pmap_unmapbios(va, sz) pmap_unmapdev(va, sz) Copied and modified: stable/7/sys/ia64/include/vm.h (from r195033, head/sys/ia64/include/vm.h) ============================================================================== --- head/sys/ia64/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/ia64/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -32,13 +32,13 @@ #include #include -/* Cache control options. */ -#define VM_CACHE_WRITE_BACK ((vm_cache_mode_t)PTE_MA_WB) -#define VM_CACHE_UNCACHEABLE ((vm_cache_mode_t)PTE_MA_UC) -#define VM_CACHE_UNCACHEABLE_EXPORTED ((vm_cache_mode_t)PTE_MA_UCE) -#define VM_CACHE_WRITE_COMBINING ((vm_cache_mode_t)PTE_MA_WC) -#define VM_CACHE_NATPAGE ((vm_cache_mode_t)PTE_MA_NATPAGE) +/* Memory attributes. */ +#define VM_MEMATTR_WRITE_BACK ((vm_memattr_t)PTE_MA_WB) +#define VM_MEMATTR_UNCACHEABLE ((vm_memattr_t)PTE_MA_UC) +#define VM_MEMATTR_UNCACHEABLE_EXPORTED ((vm_memattr_t)PTE_MA_UCE) +#define VM_MEMATTR_WRITE_COMBINING ((vm_memattr_t)PTE_MA_WC) +#define VM_MEMATTR_NATPAGE ((vm_memattr_t)PTE_MA_NATPAGE) -#define VM_CACHE_DEFAULT VM_CACHE_WRITE_BACK +#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/kern/kern_mbuf.c ============================================================================== --- stable/7/sys/kern/kern_mbuf.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/kern/kern_mbuf.c Fri Sep 4 19:59:32 2009 (r196838) @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include @@ -233,9 +235,6 @@ static void mb_zfini_pack(void *, int); static void mb_reclaim(void *); static void mbuf_init(void *); static void *mbuf_jumbo_alloc(uma_zone_t, int, u_int8_t *, int); -static void mbuf_jumbo_free(void *, int, u_int8_t); - -static MALLOC_DEFINE(M_JUMBOFRAME, "jumboframes", "mbuf jumbo frame buffers"); /* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */ CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); @@ -297,7 +296,6 @@ mbuf_init(void *dummy) if (nmbjumbo9 > 0) uma_zone_set_max(zone_jumbo9, nmbjumbo9); uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); - uma_zone_set_freef(zone_jumbo9, mbuf_jumbo_free); zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, mb_ctor_clust, mb_dtor_clust, @@ -310,7 +308,6 @@ mbuf_init(void *dummy) if (nmbjumbo16 > 0) uma_zone_set_max(zone_jumbo16, nmbjumbo16); uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); - uma_zone_set_freef(zone_jumbo16, mbuf_jumbo_free); zone_ext_refcnt = uma_zcreate(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), NULL, NULL, @@ -359,18 +356,8 @@ mbuf_jumbo_alloc(uma_zone_t zone, int by /* Inform UMA that this allocator uses kernel_map/object. */ *flags = UMA_SLAB_KERNEL; - return (contigmalloc(bytes, M_JUMBOFRAME, wait, (vm_paddr_t)0, - ~(vm_paddr_t)0, 1, 0)); -} - -/* - * UMA backend page deallocator for the jumbo frame zones. - */ -static void -mbuf_jumbo_free(void *mem, int size, u_int8_t flags) -{ - - contigfree(mem, size, M_JUMBOFRAME); + return ((void *)kmem_alloc_contig(kernel_map, bytes, wait, + (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0, VM_MEMATTR_DEFAULT)); } /* Modified: stable/7/sys/powerpc/include/pmap.h ============================================================================== --- stable/7/sys/powerpc/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/powerpc/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -72,7 +72,9 @@ struct md_page { extern struct pmap kernel_pmap_store; #define kernel_pmap (&kernel_pmap_store) +#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT #define pmap_page_is_mapped(m) (!LIST_EMPTY(&(m)->md.mdpg_pvoh)) +#define pmap_page_set_memattr(m, ma) (void)0 #ifdef _KERNEL Copied and modified: stable/7/sys/powerpc/include/vm.h (from r195033, head/sys/powerpc/include/vm.h) ============================================================================== --- head/sys/powerpc/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/powerpc/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -31,10 +31,12 @@ #include -/* Cache control options. */ -#define VM_CACHE_INHIBIT ((vm_cache_mode_t)PTE_I) -#define VM_CACHE_WRITE_THROUGH ((vm_cache_mode_t)PTE_W) +/* Memory attributes. */ +#define VM_MEMATTR_CACHING_INHIBIT ((vm_memattr_t)PTE_I) +#define VM_MEMATTR_GUARD ((vm_memattr_t)PTE_G) +#define VM_MEMATTR_MEMORY_COHERENCE ((vm_memattr_t)PTE_M) +#define VM_MEMATTR_WRITE_THROUGH ((vm_memattr_t)PTE_W) -#define VM_CACHE_DEFAULT 0 +#define VM_MEMATTR_DEFAULT 0 #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/sparc64/include/pmap.h ============================================================================== --- stable/7/sys/sparc64/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/sparc64/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -77,6 +77,9 @@ struct pmap { #define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) #define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) +#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT +#define pmap_page_set_memattr(m, ma) (void)0 + void pmap_bootstrap(vm_offset_t ekva); vm_paddr_t pmap_kextract(vm_offset_t va); void pmap_kenter(vm_offset_t va, vm_page_t m); Copied and modified: stable/7/sys/sparc64/include/vm.h (from r195033, head/sys/sparc64/include/vm.h) ============================================================================== --- head/sys/sparc64/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/sparc64/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -29,7 +29,7 @@ #ifndef _MACHINE_VM_H_ #define _MACHINE_VM_H_ -/* Cache control is not (yet) implemented. */ -#define VM_CACHE_DEFAULT 0 +/* Memory attribute configuration is not (yet) implemented. */ +#define VM_MEMATTR_DEFAULT 0 #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/sun4v/include/pmap.h ============================================================================== --- stable/7/sys/sun4v/include/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/sun4v/include/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -106,7 +106,9 @@ typedef struct pv_entry { TAILQ_ENTRY(pv_entry) pv_plist; } *pv_entry_t; +#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) +#define pmap_page_set_memattr(m, ma) (void)0 void pmap_bootstrap(vm_offset_t ekva); vm_paddr_t pmap_kextract(vm_offset_t va); Copied and modified: stable/7/sys/sun4v/include/vm.h (from r195033, head/sys/sun4v/include/vm.h) ============================================================================== --- head/sys/sun4v/include/vm.h Fri Jun 26 04:47:43 2009 (r195033, copy source) +++ stable/7/sys/sun4v/include/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -29,7 +29,7 @@ #ifndef _MACHINE_VM_H_ #define _MACHINE_VM_H_ -/* Cache control is not (yet) implemented. */ -#define VM_CACHE_DEFAULT 0 +/* Memory attribute configuration is not (yet) implemented. */ +#define VM_MEMATTR_DEFAULT 0 #endif /* !_MACHINE_PMAP_H_ */ Modified: stable/7/sys/sun4v/sun4v/pmap.c ============================================================================== --- stable/7/sys/sun4v/sun4v/pmap.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/sun4v/sun4v/pmap.c Fri Sep 4 19:59:32 2009 (r196838) @@ -1298,7 +1298,7 @@ pmap_alloc_zeroed_contig_pages(int npage while (m == NULL) { for (i = 0; phys_avail[i + 1] != 0; i += 2) { m = vm_phys_alloc_contig(npages, phys_avail[i], - phys_avail[i + 1], alignment, (1UL<<34)); + phys_avail[i + 1], alignment, (1UL<<34)); if (m) goto found; } Modified: stable/7/sys/vm/device_pager.c ============================================================================== --- stable/7/sys/vm/device_pager.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/vm/device_pager.c Fri Sep 4 19:59:32 2009 (r196838) @@ -70,9 +70,9 @@ static struct mtx dev_pager_mtx; static uma_zone_t fakepg_zone; -static vm_page_t dev_pager_getfake(vm_paddr_t); +static vm_page_t dev_pager_getfake(vm_paddr_t, vm_memattr_t); static void dev_pager_putfake(vm_page_t); -static void dev_pager_updatefake(vm_page_t, vm_paddr_t); +static void dev_pager_updatefake(vm_page_t, vm_paddr_t, vm_memattr_t); struct pagerops devicepagerops = { .pgo_init = dev_pager_init, @@ -194,7 +194,7 @@ dev_pager_dealloc(object) /* * Free up our fake pages. */ - while ((m = TAILQ_FIRST(&object->un_pager.devp.devp_pglist)) != 0) { + while ((m = TAILQ_FIRST(&object->un_pager.devp.devp_pglist)) != NULL) { TAILQ_REMOVE(&object->un_pager.devp.devp_pglist, m, pageq); dev_pager_putfake(m); } @@ -209,7 +209,8 @@ dev_pager_getpages(object, m, count, req { vm_pindex_t offset; vm_paddr_t paddr; - vm_page_t page; + vm_page_t m_paddr, page; + vm_memattr_t memattr; struct cdev *dev; int i, ret; int prot; @@ -219,7 +220,9 @@ dev_pager_getpages(object, m, count, req VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); dev = object->handle; - offset = m[reqpage]->pindex; + page = m[reqpage]; + offset = page->pindex; + memattr = object->memattr; VM_OBJECT_UNLOCK(object); csw = dev_refthread(dev); if (csw == NULL) @@ -233,14 +236,20 @@ dev_pager_getpages(object, m, count, req KASSERT(ret == 0, ("dev_pager_getpage: map function returns error")); td->td_fpop = fpop; dev_relthread(dev); - - if ((m[reqpage]->flags & PG_FICTITIOUS) != 0) { + /* If "paddr" is a real page, perform a sanity check on "memattr". */ + if ((m_paddr = vm_phys_paddr_to_vm_page(paddr)) != NULL && + pmap_page_get_memattr(m_paddr) != memattr) { + memattr = pmap_page_get_memattr(m_paddr); + printf( + "WARNING: A device driver has set \"memattr\" inconsistently.\n"); + } + if ((page->flags & PG_FICTITIOUS) != 0) { /* * If the passed in reqpage page is a fake page, update it with * the new physical address. */ VM_OBJECT_LOCK(object); - dev_pager_updatefake(m[reqpage], paddr); + dev_pager_updatefake(page, paddr, memattr); if (count > 1) { vm_page_lock_queues(); for (i = 0; i < count; i++) { @@ -254,7 +263,7 @@ dev_pager_getpages(object, m, count, req * Replace the passed in reqpage page with our own fake page and * free up the all of the original pages. */ - page = dev_pager_getfake(paddr); + page = dev_pager_getfake(paddr, memattr); VM_OBJECT_LOCK(object); TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist, page, pageq); vm_page_lock_queues(); @@ -264,7 +273,7 @@ dev_pager_getpages(object, m, count, req vm_page_insert(page, object, offset); m[reqpage] = page; } - + page->valid = VM_PAGE_BITS_ALL; return (VM_PAGER_OK); } @@ -294,48 +303,48 @@ dev_pager_haspage(object, pindex, before } /* - * Instantiate a fictitious page. Unlike physical memory pages, only - * the machine-independent fields must be initialized. + * Create a fictitious page with the specified physical address and memory + * attribute. The memory attribute is the only the machine-dependent aspect + * of a fictitious page that must be initialized. */ static vm_page_t -dev_pager_getfake(paddr) - vm_paddr_t paddr; +dev_pager_getfake(vm_paddr_t paddr, vm_memattr_t memattr) { vm_page_t m; - m = uma_zalloc(fakepg_zone, M_WAITOK); - + m = uma_zalloc(fakepg_zone, M_WAITOK | M_ZERO); + m->phys_addr = paddr; + /* Fictitious pages don't use "segind". */ m->flags = PG_FICTITIOUS; + /* Fictitious pages don't use "order" or "pool". */ m->oflags = VPO_BUSY; - m->valid = VM_PAGE_BITS_ALL; - m->dirty = 0; - m->busy = 0; - m->queue = PQ_NONE; - m->object = NULL; - m->wire_count = 1; - m->hold_count = 0; - m->phys_addr = paddr; - + pmap_page_set_memattr(m, memattr); return (m); } +/* + * Release a fictitious page. + */ static void -dev_pager_putfake(m) - vm_page_t m; +dev_pager_putfake(vm_page_t m) { + if (!(m->flags & PG_FICTITIOUS)) panic("dev_pager_putfake: bad page"); uma_zfree(fakepg_zone, m); } +/* + * Update the given fictitious page to the specified physical address and + * memory attribute. + */ static void -dev_pager_updatefake(m, paddr) - vm_page_t m; - vm_paddr_t paddr; +dev_pager_updatefake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr) { + if (!(m->flags & PG_FICTITIOUS)) panic("dev_pager_updatefake: bad page"); m->phys_addr = paddr; - m->valid = VM_PAGE_BITS_ALL; + pmap_page_set_memattr(m, memattr); } Modified: stable/7/sys/vm/pmap.h ============================================================================== --- stable/7/sys/vm/pmap.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/vm/pmap.h Fri Sep 4 19:59:32 2009 (r196838) @@ -79,10 +79,16 @@ struct pmap_statistics { }; typedef struct pmap_statistics *pmap_statistics_t; +/* + * Each machine dependent implementation is expected to provide: + * + * vm_memattr_t pmap_page_get_memattr(vm_page_t); + * boolean_t pmap_page_is_mapped(vm_page_t); + * void pmap_page_set_memattr(vm_page_t, vm_memattr_t); + */ #include #ifdef _KERNEL -struct proc; struct thread; /* Modified: stable/7/sys/vm/vm.h ============================================================================== --- stable/7/sys/vm/vm.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/vm/vm.h Fri Sep 4 19:59:32 2009 (r196838) @@ -61,6 +61,14 @@ #ifndef VM_H #define VM_H +#include + +/* + * The exact set of memory attributes is machine dependent. However, every + * machine is required to define VM_MEMATTR_DEFAULT. + */ +typedef char vm_memattr_t; /* memory attribute codes */ + typedef char vm_inherit_t; /* inheritance codes */ #define VM_INHERIT_SHARE ((vm_inherit_t) 0) Modified: stable/7/sys/vm/vm_contig.c ============================================================================== --- stable/7/sys/vm/vm_contig.c Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/vm/vm_contig.c Fri Sep 4 19:59:32 2009 (r196838) @@ -193,37 +193,37 @@ vm_page_release_contig(vm_page_t m, vm_p * specified through the given flags, then the pages are zeroed * before they are mapped. */ -static void * -contigmapping(vm_page_t m, vm_pindex_t npages, int flags) +static vm_offset_t +contigmapping(vm_map_t map, vm_size_t size, vm_page_t m, vm_memattr_t memattr, + int flags) { vm_object_t object = kernel_object; - vm_map_t map = kernel_map; vm_offset_t addr, tmp_addr; - vm_pindex_t i; vm_map_lock(map); - if (vm_map_findspace(map, vm_map_min(map), npages << PAGE_SHIFT, &addr) - != KERN_SUCCESS) { + if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { vm_map_unlock(map); - return (NULL); + return (0); } vm_object_reference(object); vm_map_insert(map, object, addr - VM_MIN_KERNEL_ADDRESS, - addr, addr + (npages << PAGE_SHIFT), VM_PROT_ALL, VM_PROT_ALL, 0); + addr, addr + size, VM_PROT_ALL, VM_PROT_ALL, 0); vm_map_unlock(map); - tmp_addr = addr; VM_OBJECT_LOCK(object); - for (i = 0; i < npages; i++) { - vm_page_insert(&m[i], object, + for (tmp_addr = addr; tmp_addr < addr + size; tmp_addr += PAGE_SIZE) { + if (memattr != VM_MEMATTR_DEFAULT) + pmap_page_set_memattr(m, memattr); + vm_page_insert(m, object, OFF_TO_IDX(tmp_addr - VM_MIN_KERNEL_ADDRESS)); - if ((flags & M_ZERO) && !(m[i].flags & PG_ZERO)) - pmap_zero_page(&m[i]); - tmp_addr += PAGE_SIZE; + if ((flags & M_ZERO) && (m->flags & PG_ZERO) == 0) + pmap_zero_page(m); + m->valid = VM_PAGE_BITS_ALL; + m++; } VM_OBJECT_UNLOCK(object); - vm_map_wire(map, addr, addr + (npages << PAGE_SHIFT), + vm_map_wire(map, addr, addr + size, VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); - return ((void *)addr); + return (addr); } void * @@ -237,11 +237,26 @@ contigmalloc( unsigned long boundary) { void *ret; + + ret = (void *)kmem_alloc_contig(kernel_map, size, flags, low, high, + alignment, boundary, VM_MEMATTR_DEFAULT); + if (ret != NULL) + malloc_type_allocated(type, round_page(size)); + return (ret); +} + +vm_offset_t +kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, vm_paddr_t low, + vm_paddr_t high, unsigned long alignment, unsigned long boundary, + vm_memattr_t memattr) +{ + vm_offset_t ret; vm_page_t pages; unsigned long npgs; int actl, actmax, inactl, inactmax, tries; - npgs = round_page(size) >> PAGE_SHIFT; + size = round_page(size); + npgs = size >> PAGE_SHIFT; tries = 0; retry: pages = vm_phys_alloc_contig(npgs, low, high, alignment, boundary); @@ -267,13 +282,11 @@ again: tries++; goto retry; } - ret = NULL; + ret = 0; } else { - ret = contigmapping(pages, npgs, flags); - if (ret == NULL) + ret = contigmapping(map, size, pages, memattr, flags); + if (ret == 0) vm_page_release_contig(pages, npgs); - else - malloc_type_allocated(type, npgs << PAGE_SHIFT); } return (ret); } @@ -281,9 +294,7 @@ again: void contigfree(void *addr, unsigned long size, struct malloc_type *type) { - vm_pindex_t npgs; - npgs = round_page(size) >> PAGE_SHIFT; kmem_free(kernel_map, (vm_offset_t)addr, size); - malloc_type_freed(type, npgs << PAGE_SHIFT); + malloc_type_freed(type, round_page(size)); } Modified: stable/7/sys/vm/vm_extern.h ============================================================================== --- stable/7/sys/vm/vm_extern.h Fri Sep 4 19:20:46 2009 (r196837) +++ stable/7/sys/vm/vm_extern.h Fri Sep 4 19:59:32 2009 (r196838) @@ -57,6 +57,9 @@ int swapon(struct thread *, void *, int int kernacc(void *, int, int); vm_offset_t kmem_alloc(vm_map_t, vm_size_t); +vm_offset_t kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags, + vm_paddr_t low, vm_paddr_t high, unsigned long alignment, + unsigned long boundary, vm_memattr_t memattr); vm_offset_t kmem_alloc_nofault(vm_map_t, vm_size_t); vm_offset_t kmem_alloc_wait(vm_map_t, vm_size_t); void kmem_free(vm_map_t, vm_offset_t, vm_size_t); Modified: stable/7/sys/vm/vm_object.c ============================================================================== --- stable/7/sys/vm/vm_object.c Fri Sep 4 19:20:46 2009 (r196837) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Fri Sep 4 22:37:03 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ABECB1065670; Fri, 4 Sep 2009 22:37:03 +0000 (UTC) (envelope-from jfv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 99D038FC0C; Fri, 4 Sep 2009 22:37:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n84Mb319022311; Fri, 4 Sep 2009 22:37:03 GMT (envelope-from jfv@svn.freebsd.org) Received: (from jfv@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n84Mb3rr022309; Fri, 4 Sep 2009 22:37:03 GMT (envelope-from jfv@svn.freebsd.org) Message-Id: <200909042237.n84Mb3rr022309@svn.freebsd.org> From: Jack F Vogel Date: Fri, 4 Sep 2009 22:37:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196843 - stable/8/sys/dev/ixgbe X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 22:37:03 -0000 Author: jfv Date: Fri Sep 4 22:37:03 2009 New Revision: 196843 URL: http://svn.freebsd.org/changeset/base/196843 Log: This patch seperates the control of header split from LRO (which it was previously dependent on), LRO gets turned off when bridging but its been found that header split is still a performance win in that case. Secondly, there was some interface specific control in stats code that has been missing, and a logic error that resulted in bogus reporting. Thanks to Manish and John of LineRateSystems for the report and help in this code. Approved by: re Modified: stable/8/sys/dev/ixgbe/ixgbe.c Modified: stable/8/sys/dev/ixgbe/ixgbe.c ============================================================================== --- stable/8/sys/dev/ixgbe/ixgbe.c Fri Sep 4 22:34:57 2009 (r196842) +++ stable/8/sys/dev/ixgbe/ixgbe.c Fri Sep 4 22:37:03 2009 (r196843) @@ -46,7 +46,7 @@ int ixgbe_display_debug_stat /********************************************************************* * Driver version *********************************************************************/ -char ixgbe_driver_version[] = "1.8.8"; +char ixgbe_driver_version[] = "1.8.9"; /********************************************************************* * PCI Device ID Table @@ -246,6 +246,15 @@ static int ixgbe_enable_msix = 1; TUNABLE_INT("hw.ixgbe.enable_msix", &ixgbe_enable_msix); /* + * Header split has seemed to be beneficial in + * all circumstances tested, so its on by default + * however this variable will allow it to be disabled + * for some debug purposes. + */ +static bool ixgbe_header_split = TRUE; +TUNABLE_INT("hw.ixgbe.hdr_split", &ixgbe_header_split); + +/* * Number of Queues, should normally * be left at 0, it then autoconfigures to * the number of cpus. Each queue is a pair @@ -454,7 +463,6 @@ ixgbe_attach(device_t dev) */ if (nmbclusters > 0 ) { int s; - /* Calculate the total RX mbuf needs */ s = (ixgbe_rxd * adapter->num_queues) * ixgbe_total_ports; if (s > nmbclusters) { device_printf(dev, "RX Descriptors exceed " @@ -1459,8 +1467,7 @@ ixgbe_msix_link(void *arg) device_printf(adapter->dev, "\nCRITICAL: ECC ERROR!! " "Please Reboot!!\n"); IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC); - } - if (reg_eicr & IXGBE_EICR_GPI_SDP1) { + } else if (reg_eicr & IXGBE_EICR_GPI_SDP1) { /* Clear the interrupt */ IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1); taskqueue_enqueue(adapter->tq, &adapter->msf_task); @@ -1883,7 +1890,11 @@ ixgbe_set_multi(struct adapter *adapter) IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCTRL, fctrl); +#if __FreeBSD_version < 800000 + IF_ADDR_LOCK(ifp); +#else if_maddr_rlock(ifp); +#endif TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; @@ -1892,7 +1903,11 @@ ixgbe_set_multi(struct adapter *adapter) IXGBE_ETH_LENGTH_OF_ADDRESS); mcnt++; } +#if __FreeBSD_version < 800000 + IF_ADDR_UNLOCK(ifp); +#else if_maddr_runlock(ifp); +#endif update_ptr = mta; ixgbe_update_mc_addr_list(&adapter->hw, @@ -3534,7 +3549,10 @@ ixgbe_setup_receive_ring(struct rx_ring rxr->next_to_check = 0; rxr->last_cleaned = 0; rxr->lro_enabled = FALSE; - rxr->hdr_split = FALSE; + + /* Use header split if configured */ + if (ixgbe_header_split) + rxr->hdr_split = TRUE; bus_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); @@ -3553,7 +3571,6 @@ ixgbe_setup_receive_ring(struct rx_ring } INIT_DEBUGOUT("RX LRO Initialized\n"); rxr->lro_enabled = TRUE; - rxr->hdr_split = TRUE; lro->ifp = adapter->ifp; } @@ -4457,24 +4474,42 @@ ixgbe_update_stats_counters(struct adapt struct ifnet *ifp = adapter->ifp;; struct ixgbe_hw *hw = &adapter->hw; u32 missed_rx = 0, bprc, lxon, lxoff, total; + u64 total_missed_rx = 0; adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); for (int i = 0; i < 8; i++) { - int mp; - mp = IXGBE_READ_REG(hw, IXGBE_MPC(i)); - missed_rx += mp; - adapter->stats.mpc[i] += mp; - adapter->stats.rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); + /* missed_rx tallies misses for the gprc workaround */ + missed_rx += IXGBE_READ_REG(hw, IXGBE_MPC(i)); + adapter->stats.mpc[i] += missed_rx; + /* Running comprehensive total for stats display */ + total_missed_rx += adapter->stats.mpc[i]; + if (hw->mac.type == ixgbe_mac_82598EB) + adapter->stats.rnbc[i] += + IXGBE_READ_REG(hw, IXGBE_RNBC(i)); } /* Hardware workaround, gprc counts missed packets */ adapter->stats.gprc += IXGBE_READ_REG(hw, IXGBE_GPRC); adapter->stats.gprc -= missed_rx; - adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCH); - adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH); - adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORH); + if (hw->mac.type == ixgbe_mac_82599EB) { + adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCL); + IXGBE_READ_REG(hw, IXGBE_GORCH); /* clears register */ + adapter->stats.gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL); + IXGBE_READ_REG(hw, IXGBE_GOTCH); /* clears register */ + adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORL); + IXGBE_READ_REG(hw, IXGBE_TORH); /* clears register */ + adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT); + adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT); + } else { + adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC); + adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC); + /* 82598 only has a counter in the high register */ + adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GORCH); + adapter->stats.gorc += IXGBE_READ_REG(hw, IXGBE_GOTCH); + adapter->stats.tor += IXGBE_READ_REG(hw, IXGBE_TORH); + } /* * Workaround: mprc hardware is incorrectly counting @@ -4494,9 +4529,6 @@ ixgbe_update_stats_counters(struct adapt adapter->stats.prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522); adapter->stats.rlec += IXGBE_READ_REG(hw, IXGBE_RLEC); - adapter->stats.lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT); - adapter->stats.lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT); - lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC); adapter->stats.lxontxc += lxon; lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC); @@ -4532,7 +4564,7 @@ ixgbe_update_stats_counters(struct adapt ifp->if_collisions = 0; /* Rx Errors */ - ifp->if_ierrors = missed_rx + adapter->stats.crcerrs + + ifp->if_ierrors = total_missed_rx + adapter->stats.crcerrs + adapter->stats.rlec; } From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 00:50:08 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B384C106566B; Sat, 5 Sep 2009 00:50:08 +0000 (UTC) (envelope-from kensmith@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A24F38FC12; Sat, 5 Sep 2009 00:50:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n850o88L028208; Sat, 5 Sep 2009 00:50:08 GMT (envelope-from kensmith@svn.freebsd.org) Received: (from kensmith@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n850o8Uf028206; Sat, 5 Sep 2009 00:50:08 GMT (envelope-from kensmith@svn.freebsd.org) Message-Id: <200909050050.n850o8Uf028206@svn.freebsd.org> From: Ken Smith Date: Sat, 5 Sep 2009 00:50:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196848 - stable/8/sys/conf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 00:50:08 -0000 Author: kensmith Date: Sat Sep 5 00:50:08 2009 New Revision: 196848 URL: http://svn.freebsd.org/changeset/base/196848 Log: Ready for BETA4. Approved by: re (implicit) Modified: stable/8/sys/conf/newvers.sh Modified: stable/8/sys/conf/newvers.sh ============================================================================== --- stable/8/sys/conf/newvers.sh Fri Sep 4 23:14:18 2009 (r196847) +++ stable/8/sys/conf/newvers.sh Sat Sep 5 00:50:08 2009 (r196848) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="8.0" -BRANCH="BETA3" +BRANCH="BETA4" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 05:28:07 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BEB561065679; Sat, 5 Sep 2009 05:28:07 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC1848FC0C; Sat, 5 Sep 2009 05:28:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n855S7ZY038176; Sat, 5 Sep 2009 05:28:07 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n855S7M0038174; Sat, 5 Sep 2009 05:28:07 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200909050528.n855S7M0038174@svn.freebsd.org> From: Alan Cox Date: Sat, 5 Sep 2009 05:28:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196852 - in stable/7/sys: . contrib/pf pc98/include X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 05:28:07 -0000 Author: alc Date: Sat Sep 5 05:28:07 2009 New Revision: 196852 URL: http://svn.freebsd.org/changeset/base/196852 Log: MFC r195089 Add stub vm.h for pc98. Added: stable/7/sys/pc98/include/vm.h - copied unchanged from r195089, head/sys/pc98/include/vm.h Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) Copied: stable/7/sys/pc98/include/vm.h (from r195089, head/sys/pc98/include/vm.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/pc98/include/vm.h Sat Sep 5 05:28:07 2009 (r196852, copy of r195089, head/sys/pc98/include/vm.h) @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 05:57:44 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FD6E106566C; Sat, 5 Sep 2009 05:57:44 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63A948FC0A; Sat, 5 Sep 2009 05:57:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n855vius038789; Sat, 5 Sep 2009 05:57:44 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n855viT4038786; Sat, 5 Sep 2009 05:57:44 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200909050557.n855viT4038786@svn.freebsd.org> From: Alan Cox Date: Sat, 5 Sep 2009 05:57:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196853 - in stable/7/sys: . contrib/pf i386/include X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 05:57:44 -0000 Author: alc Date: Sat Sep 5 05:57:44 2009 New Revision: 196853 URL: http://svn.freebsd.org/changeset/base/196853 Log: MFC r194295 Move (read|write)_cyrix_reg() inlines from specialreg.h to cpufunc.h. specialreg.h now consists solely of register-related macros. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/i386/include/cpufunc.h stable/7/sys/i386/include/specialreg.h Modified: stable/7/sys/i386/include/cpufunc.h ============================================================================== --- stable/7/sys/i386/include/cpufunc.h Sat Sep 5 05:28:07 2009 (r196852) +++ stable/7/sys/i386/include/cpufunc.h Sat Sep 5 05:57:44 2009 (r196853) @@ -646,6 +646,20 @@ load_dr7(u_int dr7) __asm __volatile("movl %0,%%dr7" : : "r" (dr7)); } +static __inline u_char +read_cyrix_reg(u_char reg) +{ + outb(0x22, reg); + return inb(0x23); +} + +static __inline void +write_cyrix_reg(u_char reg, u_char data) +{ + outb(0x22, reg); + outb(0x23, data); +} + static __inline register_t intr_disable(void) { @@ -720,6 +734,7 @@ u_int rdr5(void); u_int rdr6(void); u_int rdr7(void); uint64_t rdtsc(void); +u_char read_cyrix_reg(u_char reg); u_int read_eflags(void); u_int rfs(void); uint64_t rgdt(void); @@ -728,6 +743,7 @@ uint64_t ridt(void); u_short rldt(void); u_short rtr(void); void wbinvd(void); +void write_cyrix_reg(u_char reg, u_char data); void write_eflags(u_int ef); void wrmsr(u_int msr, uint64_t newval); Modified: stable/7/sys/i386/include/specialreg.h ============================================================================== --- stable/7/sys/i386/include/specialreg.h Sat Sep 5 05:28:07 2009 (r196852) +++ stable/7/sys/i386/include/specialreg.h Sat Sep 5 05:57:44 2009 (r196853) @@ -540,20 +540,4 @@ #define VIA_CRYPT_CWLO_KEY192 0x0000040c /* 192bit, 12 rds */ #define VIA_CRYPT_CWLO_KEY256 0x0000080e /* 256bit, 15 rds */ -#ifndef LOCORE -static __inline u_char -read_cyrix_reg(u_char reg) -{ - outb(0x22, reg); - return inb(0x23); -} - -static __inline void -write_cyrix_reg(u_char reg, u_char data) -{ - outb(0x22, reg); - outb(0x23, data); -} -#endif - #endif /* !_MACHINE_SPECIALREG_H_ */ From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 06:24:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79FCA1065670; Sat, 5 Sep 2009 06:24:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 317098FC14; Sat, 5 Sep 2009 06:24:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n856OTAe039346; Sat, 5 Sep 2009 06:24:29 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n856OTob039344; Sat, 5 Sep 2009 06:24:29 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200909050624.n856OTob039344@svn.freebsd.org> From: Alexander Motin Date: Sat, 5 Sep 2009 06:24:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196854 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/ahci dev/xen/xenpci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 06:24:30 -0000 Author: mav Date: Sat Sep 5 06:24:28 2009 New Revision: 196854 URL: http://svn.freebsd.org/changeset/base/196854 Log: MFC r196777, r196796: ATI SB600 can't handle 256 sectors transfers with FPDMA (NCQ). Approved by: re (ATA-CAM blanket) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ahci/ahci.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ahci/ahci.c ============================================================================== --- stable/8/sys/dev/ahci/ahci.c Sat Sep 5 05:57:44 2009 (r196853) +++ stable/8/sys/dev/ahci/ahci.c Sat Sep 5 06:24:28 2009 (r196854) @@ -1942,6 +1942,9 @@ ahciaction(struct cam_sim *sim, union cc cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = MAXPHYS; + /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ + if (pci_get_devid(device_get_parent(dev)) == 0x43801002) + cpi->maxio = min(cpi->maxio, 128 * 512); cpi->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 08:03:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66A62106566B; Sat, 5 Sep 2009 08:03:29 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 533488FC0C; Sat, 5 Sep 2009 08:03:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8583T2Z041319; Sat, 5 Sep 2009 08:03:29 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8583TOM041317; Sat, 5 Sep 2009 08:03:29 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200909050803.n8583TOM041317@svn.freebsd.org> From: Warner Losh Date: Sat, 5 Sep 2009 08:03:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196855 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 08:03:29 -0000 Author: imp Date: Sat Sep 5 08:03:29 2009 New Revision: 196855 URL: http://svn.freebsd.org/changeset/base/196855 Log: MFC r196529: Rather than having enabled/disabled, implement a max queue depth. While usually not an issue, this firewalls bugs in the code that may run us out of memory. Fix a memory exhaustion in the case where devctl was disabled, but the link was bouncing. The check to queue was in the wrong place. Implement a new sysctl hw.bus.devctl_queue to control the depth. Make compatibility hacks for hw.bus.devctl_disable to ease transition. Reviewed by: emaste@ Approved by: re@ (kib) MFC after: asap Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/kern/subr_bus.c Modified: stable/8/sys/kern/subr_bus.c ============================================================================== --- stable/8/sys/kern/subr_bus.c Sat Sep 5 06:24:28 2009 (r196854) +++ stable/8/sys/kern/subr_bus.c Sat Sep 5 08:03:29 2009 (r196855) @@ -350,11 +350,18 @@ device_sysctl_fini(device_t dev) * tested since 3.4 or 2.2.8! */ +/* Deprecated way to adjust queue length */ static int sysctl_devctl_disable(SYSCTL_HANDLER_ARGS); -static int devctl_disable = 0; -TUNABLE_INT("hw.bus.devctl_disable", &devctl_disable); +/* XXX Need to support old-style tunable hw.bus.devctl_disable" */ SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RW, NULL, - 0, sysctl_devctl_disable, "I", "devctl disable"); + 0, sysctl_devctl_disable, "I", "devctl disable -- deprecated"); + +#define DEVCTL_DEFAULT_QUEUE_LEN 1000 +static int sysctl_devctl_queue(SYSCTL_HANDLER_ARGS); +static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; +TUNABLE_INT("hw.bus.devctl_queue", &devctl_queue_length); +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RW, NULL, + 0, sysctl_devctl_queue, "I", "devctl queue length"); static d_open_t devopen; static d_close_t devclose; @@ -385,6 +392,7 @@ static struct dev_softc { int inuse; int nonblock; + int queued; struct mtx mtx; struct cv cv; struct selinfo sel; @@ -423,7 +431,7 @@ devclose(struct cdev *dev, int fflag, in mtx_lock(&devsoftc.mtx); cv_broadcast(&devsoftc.cv); mtx_unlock(&devsoftc.mtx); - + devsoftc.async_proc = NULL; return (0); } @@ -458,6 +466,7 @@ devread(struct cdev *dev, struct uio *ui } n1 = TAILQ_FIRST(&devsoftc.devq); TAILQ_REMOVE(&devsoftc.devq, n1, dei_link); + devsoftc.queued--; mtx_unlock(&devsoftc.mtx); rv = uiomove(n1->dei_data, strlen(n1->dei_data), uio); free(n1->dei_data, M_BUS); @@ -531,21 +540,33 @@ devctl_process_running(void) void devctl_queue_data(char *data) { - struct dev_event_info *n1 = NULL; + struct dev_event_info *n1 = NULL, *n2 = NULL; struct proc *p; - /* - * Do not allow empty strings to be queued, as they - * cause devd to exit prematurely. - */ if (strlen(data) == 0) return; + if (devctl_queue_length == 0) + return; n1 = malloc(sizeof(*n1), M_BUS, M_NOWAIT); if (n1 == NULL) return; n1->dei_data = data; mtx_lock(&devsoftc.mtx); + if (devctl_queue_length == 0) { + free(n1->dei_data, M_BUS); + free(n1, M_BUS); + return; + } + /* Leave at least one spot in the queue... */ + while (devsoftc.queued > devctl_queue_length - 1) { + n2 = TAILQ_FIRST(&devsoftc.devq); + TAILQ_REMOVE(&devsoftc.devq, n2, dei_link); + free(n2->dei_data, M_BUS); + free(n2, M_BUS); + devsoftc.queued--; + } TAILQ_INSERT_TAIL(&devsoftc.devq, n1, dei_link); + devsoftc.queued++; cv_broadcast(&devsoftc.cv); mtx_unlock(&devsoftc.mtx); selwakeup(&devsoftc.sel); @@ -614,7 +635,7 @@ devaddq(const char *type, const char *wh char *pnp = NULL; const char *parstr; - if (devctl_disable) + if (!devctl_queue_length)/* Rare race, but lost races safely discard */ return; data = malloc(1024, M_BUS, M_NOWAIT); if (data == NULL) @@ -731,12 +752,11 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARG struct dev_event_info *n1; int dis, error; - dis = devctl_disable; + dis = devctl_queue_length == 0; error = sysctl_handle_int(oidp, &dis, 0, req); if (error || !req->newptr) return (error); mtx_lock(&devsoftc.mtx); - devctl_disable = dis; if (dis) { while (!TAILQ_EMPTY(&devsoftc.devq)) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -744,6 +764,35 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARG free(n1->dei_data, M_BUS); free(n1, M_BUS); } + devsoftc.queued = 0; + devctl_queue_length = 0; + } else { + devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; + } + mtx_unlock(&devsoftc.mtx); + return (0); +} + +static int +sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) +{ + struct dev_event_info *n1; + int q, error; + + q = devctl_queue_length; + error = sysctl_handle_int(oidp, &q, 0, req); + if (error || !req->newptr) + return (error); + if (q < 0) + return (EINVAL); + mtx_lock(&devsoftc.mtx); + devctl_queue_length = q; + while (devsoftc.queued > devctl_queue_length) { + n1 = TAILQ_FIRST(&devsoftc.devq); + TAILQ_REMOVE(&devsoftc.devq, n1, dei_link); + free(n1->dei_data, M_BUS); + free(n1, M_BUS); + devsoftc.queued--; } mtx_unlock(&devsoftc.mtx); return (0); @@ -886,7 +935,7 @@ devclass_find_internal(const char *class if (create && !dc) { PDEBUG(("creating %s", classname)); dc = malloc(sizeof(struct devclass) + strlen(classname) + 1, - M_BUS, M_NOWAIT|M_ZERO); + M_BUS, M_NOWAIT | M_ZERO); if (!dc) return (NULL); dc->parent = NULL; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 13:10:55 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19935106566C; Sat, 5 Sep 2009 13:10:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 06F058FC16; Sat, 5 Sep 2009 13:10:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85DAsxP053770; Sat, 5 Sep 2009 13:10:54 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85DAskt053768; Sat, 5 Sep 2009 13:10:54 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200909051310.n85DAskt053768@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 Sep 2009 13:10:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196859 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci fs/pseudofs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 13:10:55 -0000 Author: kib Date: Sat Sep 5 13:10:54 2009 New Revision: 196859 URL: http://svn.freebsd.org/changeset/base/196859 Log: MFC r196689: Remove spurious pfs_unlock(). Approved by: re (rwatson) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/fs/pseudofs/pseudofs_vnops.c Modified: stable/8/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- stable/8/sys/fs/pseudofs/pseudofs_vnops.c Sat Sep 5 08:38:25 2009 (r196858) +++ stable/8/sys/fs/pseudofs/pseudofs_vnops.c Sat Sep 5 13:10:54 2009 (r196859) @@ -339,7 +339,6 @@ pfs_getextattr(struct vop_getextattr_arg if (proc != NULL) PROC_UNLOCK(proc); - pfs_unlock(pn); PFS_RETURN (error); } From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 13:31:16 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EF25106568F; Sat, 5 Sep 2009 13:31:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D6808FC14; Sat, 5 Sep 2009 13:31:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85DVGdh054246; Sat, 5 Sep 2009 13:31:16 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85DVGPb054244; Sat, 5 Sep 2009 13:31:16 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200909051331.n85DVGPb054244@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 Sep 2009 13:31:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196860 - in stable/7/sys: . contrib/pf fs/pseudofs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 13:31:16 -0000 Author: kib Date: Sat Sep 5 13:31:16 2009 New Revision: 196860 URL: http://svn.freebsd.org/changeset/base/196860 Log: MFC r196689: Remove spurious pfs_unlock(). Approved by: re (rwatson) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/fs/pseudofs/pseudofs_vnops.c Modified: stable/7/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- stable/7/sys/fs/pseudofs/pseudofs_vnops.c Sat Sep 5 13:10:54 2009 (r196859) +++ stable/7/sys/fs/pseudofs/pseudofs_vnops.c Sat Sep 5 13:31:16 2009 (r196860) @@ -339,7 +339,6 @@ pfs_getextattr(struct vop_getextattr_arg if (proc != NULL) PROC_UNLOCK(proc); - pfs_unlock(pn); PFS_RETURN (error); } From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 15:01:57 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0552D106566B; Sat, 5 Sep 2009 15:01:57 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CD3998FC08; Sat, 5 Sep 2009 15:01:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85F1umf056567; Sat, 5 Sep 2009 15:01:56 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85F1upm056564; Sat, 5 Sep 2009 15:01:56 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <200909051501.n85F1upm056564@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 5 Sep 2009 15:01:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196862 - in stable/8/lib/libc: . posix1e stdio stdtime string X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 15:01:57 -0000 Author: trasz Date: Sat Sep 5 15:01:56 2009 New Revision: 196862 URL: http://svn.freebsd.org/changeset/base/196862 Log: MFC r196740: Fix regression introduced with NFSv4 ACL support - make acl_to_text(3) and acl_calc_mask(3) return error instead of crashing when acl passed to them is NULL. Submitted by: markus Reviewed by: rwatson Approved by: re (kib) Modified: stable/8/lib/libc/ (props changed) stable/8/lib/libc/posix1e/acl_calc_mask.c stable/8/lib/libc/posix1e/acl_to_text.c stable/8/lib/libc/stdio/asprintf.c (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/string/ffsll.c (props changed) stable/8/lib/libc/string/flsll.c (props changed) stable/8/lib/libc/string/wcpcpy.c (props changed) stable/8/lib/libc/string/wcpncpy.c (props changed) Modified: stable/8/lib/libc/posix1e/acl_calc_mask.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_calc_mask.c Sat Sep 5 13:32:05 2009 (r196861) +++ stable/8/lib/libc/posix1e/acl_calc_mask.c Sat Sep 5 15:01:56 2009 (r196862) @@ -50,12 +50,6 @@ acl_calc_mask(acl_t *acl_p) acl_t acl_new; int i, mask_mode, mask_num; - if (!_acl_brand_may_be(*acl_p, ACL_BRAND_POSIX)) { - errno = EINVAL; - return (-1); - } - _acl_brand_as(*acl_p, ACL_BRAND_POSIX); - /* * (23.4.2.4) requires acl_p to point to a pointer to a valid ACL. * Since one of the primary reasons to use this function would be @@ -67,6 +61,13 @@ acl_calc_mask(acl_t *acl_p) errno = EINVAL; return (-1); } + + if (!_acl_brand_may_be(*acl_p, ACL_BRAND_POSIX)) { + errno = EINVAL; + return (-1); + } + _acl_brand_as(*acl_p, ACL_BRAND_POSIX); + acl_int = &(*acl_p)->ats_acl; if ((acl_int->acl_cnt < 3) || (acl_int->acl_cnt > ACL_MAX_ENTRIES)) { errno = EINVAL; Modified: stable/8/lib/libc/posix1e/acl_to_text.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_to_text.c Sat Sep 5 13:32:05 2009 (r196861) +++ stable/8/lib/libc/posix1e/acl_to_text.c Sat Sep 5 15:01:56 2009 (r196862) @@ -70,11 +70,6 @@ _posix1e_acl_to_text(acl_t acl, ssize_t if (buf == NULL) return(NULL); - if (acl == NULL) { - errno = EINVAL; - return(NULL); - } - acl_int = &acl->ats_acl; mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */ @@ -243,6 +238,11 @@ char * acl_to_text_np(acl_t acl, ssize_t *len_p, int flags) { + if (acl == NULL) { + errno = EINVAL; + return(NULL); + } + switch (_acl_brand(acl)) { case ACL_BRAND_POSIX: return (_posix1e_acl_to_text(acl, len_p, flags)); From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 17:29:08 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BEE791065696; Sat, 5 Sep 2009 17:29:08 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AD7178FC0C; Sat, 5 Sep 2009 17:29:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85HT8wo059715; Sat, 5 Sep 2009 17:29:08 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85HT8lc059714; Sat, 5 Sep 2009 17:29:08 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200909051729.n85HT8lc059714@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sat, 5 Sep 2009 17:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196867 - stable/8/usr.sbin/ndp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 17:29:08 -0000 Author: bz Date: Sat Sep 5 17:29:08 2009 New Revision: 196867 URL: http://svn.freebsd.org/changeset/base/196867 Log: MFC r196866: In the NEXTADDR macro use SA_SIZE() rather than directly using sizeof(), as introduced in r186119, for advancing the current position into the buffer. See comment in net/route.h for a description of the difference. This makes ndp -s work again. Reviewed by: qingli Approved by: re (kib) Modified: stable/8/usr.sbin/ndp/ (props changed) stable/8/usr.sbin/ndp/ndp.c Modified: stable/8/usr.sbin/ndp/ndp.c ============================================================================== --- stable/8/usr.sbin/ndp/ndp.c Sat Sep 5 16:51:51 2009 (r196866) +++ stable/8/usr.sbin/ndp/ndp.c Sat Sep 5 17:29:08 2009 (r196867) @@ -116,7 +116,7 @@ #define NEXTADDR(w, s) \ if (rtm->rtm_addrs & (w)) { \ - bcopy((char *)&s, cp, sizeof(s)); cp += sizeof(s);} + bcopy((char *)&s, cp, sizeof(s)); cp += SA_SIZE(&s);} static pid_t pid; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 17:35:31 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BD41106566B; Sat, 5 Sep 2009 17:35:31 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4905D8FC0A; Sat, 5 Sep 2009 17:35:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85HZVaY059895; Sat, 5 Sep 2009 17:35:31 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85HZVNd059893; Sat, 5 Sep 2009 17:35:31 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200909051735.n85HZVNd059893@svn.freebsd.org> From: Qing Li Date: Sat, 5 Sep 2009 17:35:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196868 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 17:35:31 -0000 Author: qingli Date: Sat Sep 5 17:35:31 2009 New Revision: 196868 URL: http://svn.freebsd.org/changeset/base/196868 Log: MFC r196865 This patch fixes an address scope violation. Considering the scenario where an anycast address is assigned on one interface, and a global address with the same scope is assigned on another interface. In other words, the interface owns the anycast address has only the link-local address as one other address. Without this patch, "ping6" the anycast address from another station will observe the source address of the returned ICMP6 echo reply has the link-local address, not the global address that exists on the other interface in the same node. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/icmp6.c Modified: stable/8/sys/netinet6/icmp6.c ============================================================================== --- stable/8/sys/netinet6/icmp6.c Sat Sep 5 17:29:08 2009 (r196867) +++ stable/8/sys/netinet6/icmp6.c Sat Sep 5 17:35:31 2009 (r196868) @@ -2170,6 +2170,10 @@ icmp6_reflect(struct mbuf *m, size_t off } } + if ((srcp != NULL) && + (in6_addrscope(srcp) != in6_addrscope(&ip6->ip6_src))) + srcp = NULL; + if (srcp == NULL) { int e; struct sockaddr_in6 sin6; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 17:40:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3F3F10656C2; Sat, 5 Sep 2009 17:40:27 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8FE378FC12; Sat, 5 Sep 2009 17:40:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85HeRcR060047; Sat, 5 Sep 2009 17:40:27 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85HeRV5060042; Sat, 5 Sep 2009 17:40:27 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200909051740.n85HeRV5060042@svn.freebsd.org> From: Qing Li Date: Sat, 5 Sep 2009 17:40:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196869 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 17:40:27 -0000 Author: qingli Date: Sat Sep 5 17:40:27 2009 New Revision: 196869 URL: http://svn.freebsd.org/changeset/base/196869 Log: MFC r196864 This patch fixes the following issues: - Interface link-local address is not reachable within the node that owns the interface, this is due to the mismatch in address scope as the result of the installed interface address loopback route. Therefore for each interface address loopback route, the rt_gateway field (of AF_LINK type) will be used to track which interface a given address belongs to. This will aid the address source to use the proper interface for address scope/zone validation. - The loopback address is not reachable. The root cause is the same as the above. - Empty nd6 entries are created for the IPv6 loopback addresses only for validation reason. Doing so will eliminate as much of the special case (loopback addresses) handling code as possible, however, these empty nd6 entries should not be returned to the userland applications such as the "ndp" command. Since both of the above issues contain common files, these files are committed together. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if_llatbl.c stable/8/sys/netinet6/in6.c stable/8/sys/netinet6/in6_src.c stable/8/sys/netinet6/ip6_output.c Modified: stable/8/sys/net/if_llatbl.c ============================================================================== --- stable/8/sys/net/if_llatbl.c Sat Sep 5 17:35:31 2009 (r196868) +++ stable/8/sys/net/if_llatbl.c Sat Sep 5 17:40:27 2009 (r196869) @@ -263,6 +263,15 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl->sdl_index); return EINVAL; } + if (ifp->if_flags & IFF_LOOPBACK) { + struct ifaddr *ia; + ia = ifa_ifwithaddr(dst); + if (ia != NULL) { + ifp = ia->ifa_ifp; + ifa_free(ia); + } else + return EINVAL; + } switch (rtm->rtm_type) { case RTM_ADD: Modified: stable/8/sys/netinet6/in6.c ============================================================================== --- stable/8/sys/netinet6/in6.c Sat Sep 5 17:35:31 2009 (r196868) +++ stable/8/sys/netinet6/in6.c Sat Sep 5 17:40:27 2009 (r196869) @@ -1201,8 +1201,8 @@ in6_purgeaddr(struct ifaddr *ifa) bzero(&null_sdl, sizeof(null_sdl)); null_sdl.sdl_len = sizeof(null_sdl); null_sdl.sdl_family = AF_LINK; - null_sdl.sdl_type = V_loif->if_type; - null_sdl.sdl_index = V_loif->if_index; + null_sdl.sdl_type = ia->ia_ifp->if_type; + null_sdl.sdl_index = ia->ia_ifp->if_index; bzero(&info, sizeof(info)); info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC; info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr; @@ -1782,9 +1782,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 if (error == 0 && rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt->rt_gateway)->sdl_type = - rt->rt_ifp->if_type; + ifp->if_type; ((struct sockaddr_dl *)rt->rt_gateway)->sdl_index = - rt->rt_ifp->if_index; + ifp->if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) @@ -2495,6 +2495,9 @@ in6_lltable_dump(struct lltable *llt, st } ndpc; int i, error; + if (ifp->if_flags & IFF_LOOPBACK) + return 0; + LLTABLE_LOCK_ASSERT(); error = 0; Modified: stable/8/sys/netinet6/in6_src.c ============================================================================== --- stable/8/sys/netinet6/in6_src.c Sat Sep 5 17:35:31 2009 (r196868) +++ stable/8/sys/netinet6/in6_src.c Sat Sep 5 17:40:27 2009 (r196869) @@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #ifdef RADIX_MPATH @@ -697,8 +698,25 @@ selectroute(struct sockaddr_in6 *dstsock if (error == EHOSTUNREACH) V_ip6stat.ip6s_noroute++; - if (retifp != NULL) + if (retifp != NULL) { *retifp = ifp; + + /* + * Adjust the "outgoing" interface. If we're going to loop + * the packet back to ourselves, the ifp would be the loopback + * interface. However, we'd rather know the interface associated + * to the destination address (which should probably be one of + * our own addresses.) + */ + if (rt) { + if ((rt->rt_ifp->if_flags & IFF_LOOPBACK) && + (rt->rt_gateway->sa_family == AF_LINK)) + *retifp = + ifnet_byindex(((struct sockaddr_dl *) + rt->rt_gateway)->sdl_index); + } + } + if (retrt != NULL) *retrt = rt; /* rt may be NULL */ @@ -750,16 +768,6 @@ in6_selectif(struct sockaddr_in6 *dstsoc return (flags); } - /* - * Adjust the "outgoing" interface. If we're going to loop the packet - * back to ourselves, the ifp would be the loopback interface. - * However, we'd rather know the interface associated to the - * destination address (which should probably be one of our own - * addresses.) - */ - if (rt && rt->rt_ifa && rt->rt_ifa->ifa_ifp) - *retifp = rt->rt_ifa->ifa_ifp; - if (ro == &sro && rt && rt == sro.ro_rt) RTFREE(rt); return (0); Modified: stable/8/sys/netinet6/ip6_output.c ============================================================================== --- stable/8/sys/netinet6/ip6_output.c Sat Sep 5 17:35:31 2009 (r196868) +++ stable/8/sys/netinet6/ip6_output.c Sat Sep 5 17:40:27 2009 (r196869) @@ -602,15 +602,12 @@ again: rt->rt_use++; } + /* * The outgoing interface must be in the zone of source and - * destination addresses. We should use ia_ifp to support the - * case of sending packets to an address of our own. + * destination addresses. */ - if (ia != NULL && ia->ia_ifp) - origifp = ia->ia_ifp; - else - origifp = ifp; + origifp = ifp; src0 = ip6->ip6_src; if (in6_setscope(&src0, origifp, &zone)) @@ -634,6 +631,12 @@ again: goto badscope; } + /* We should use ia_ifp to support the case of + * sending packets to an address of our own. + */ + if (ia != NULL && ia->ia_ifp) + ifp = ia->ia_ifp; + /* scope check is done. */ goto routefound; From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 18:44:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D15C11065672; Sat, 5 Sep 2009 18:44:36 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C036C8FC0A; Sat, 5 Sep 2009 18:44:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85Iiajq061375; Sat, 5 Sep 2009 18:44:36 GMT (envelope-from rodrigc@svn.freebsd.org) Received: (from rodrigc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85IiaNs061373; Sat, 5 Sep 2009 18:44:36 GMT (envelope-from rodrigc@svn.freebsd.org) Message-Id: <200909051844.n85IiaNs061373@svn.freebsd.org> From: Craig Rodrigues Date: Sat, 5 Sep 2009 18:44:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196870 - stable/7/etc/rc.d X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 18:44:36 -0000 Author: rodrigc Date: Sat Sep 5 18:44:36 2009 New Revision: 196870 URL: http://svn.freebsd.org/changeset/base/196870 Log: This set of MFC's brings savecore closer to the trunk version. Now, crashinfo will only be run if the following conditions are true: - savecore -C determines that a crash dump exists - crashinfo_enable="YES" MFC: 182460 Add the ability to run /usr/sbin/crashinfo on a new core dump automatically during boot. MFC: 180318 Remove the $DUMPDIR variable. It's redundant and the rest of the script uses $dumpdir directly. MFC: 180317 Make checking for the availability of core dumps work in the case that $dumpdev is not set to "AUTO". Modified: stable/7/etc/rc.d/savecore Modified: stable/7/etc/rc.d/savecore ============================================================================== --- stable/7/etc/rc.d/savecore Sat Sep 5 17:40:27 2009 (r196869) +++ stable/7/etc/rc.d/savecore Sat Sep 5 18:44:36 2009 (r196870) @@ -52,10 +52,25 @@ savecore_prestart() savecore_start() { + local dev + + case "${dumpdev}" in + [Aa][Uu][Tt][Oo]) + dev= + ;; + *) + dev="${dumpdev}" + ;; + esac + echo "Checking for core dump on ${dumpdev}..." - savecore ${savecore_flags} ${dumpdir} ${dumpdev} - if checkyesno crashinfo_enable; then - ${crashinfo_program} -d ${dumpdir} + if savecore -C "${dumpdir}" "${dev}" >/dev/null; then + savecore ${savecore_flags} ${dumpdir} ${dumpdev} + if checkyesno crashinfo_enable; then + ${crashinfo_program} -d ${dumpdir} + fi + else + [ -z "${rc_quiet}" ] && echo "No core dumps found" fi } From owner-svn-src-stable@FreeBSD.ORG Sat Sep 5 20:35:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E04C1106568B; Sat, 5 Sep 2009 20:35:18 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B3D698FC13; Sat, 5 Sep 2009 20:35:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n85KZI5u063439; Sat, 5 Sep 2009 20:35:18 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n85KZIee063436; Sat, 5 Sep 2009 20:35:18 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <200909052035.n85KZIee063436@svn.freebsd.org> From: Qing Li Date: Sat, 5 Sep 2009 20:35:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196872 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2009 20:35:19 -0000 Author: qingli Date: Sat Sep 5 20:35:18 2009 New Revision: 196872 URL: http://svn.freebsd.org/changeset/base/196872 Log: MFC r196871 The addresses that are assigned to the loopback interface should be part of the kernel routing table. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if_llatbl.c stable/8/sys/netinet6/in6.c Modified: stable/8/sys/net/if_llatbl.c ============================================================================== --- stable/8/sys/net/if_llatbl.c Sat Sep 5 20:24:37 2009 (r196871) +++ stable/8/sys/net/if_llatbl.c Sat Sep 5 20:35:18 2009 (r196872) @@ -263,15 +263,6 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl->sdl_index); return EINVAL; } - if (ifp->if_flags & IFF_LOOPBACK) { - struct ifaddr *ia; - ia = ifa_ifwithaddr(dst); - if (ia != NULL) { - ifp = ia->ifa_ifp; - ifa_free(ia); - } else - return EINVAL; - } switch (rtm->rtm_type) { case RTM_ADD: Modified: stable/8/sys/netinet6/in6.c ============================================================================== --- stable/8/sys/netinet6/in6.c Sat Sep 5 20:24:37 2009 (r196871) +++ stable/8/sys/netinet6/in6.c Sat Sep 5 20:35:18 2009 (r196872) @@ -1192,9 +1192,10 @@ in6_purgeaddr(struct ifaddr *ifa) /* * Remove the loopback route to the interface address. - * The check for the current setting of "nd6_useloopback" is not needed. + * The check for the current setting of "nd6_useloopback" + * is not needed. */ - if (!(ia->ia_ifp->if_flags & IFF_LOOPBACK)) { + { struct rt_addrinfo info; struct sockaddr_dl null_sdl; @@ -1767,7 +1768,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 /* * add a loopback route to self */ - if (V_nd6_useloopback && !(ifp->if_flags & IFF_LOOPBACK)) { + if (!(ia->ia_flags & IFA_ROUTE) + && (V_nd6_useloopback + || (ifp->if_flags & IFF_LOOPBACK))) { struct rt_addrinfo info; struct rtentry *rt = NULL; static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; @@ -1788,7 +1791,7 @@ in6_ifinit(struct ifnet *ifp, struct in6 RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) - log(LOG_INFO, "in6_ifinit: insertion failed\n"); + log(LOG_INFO, "in6_ifinit: error = %d, insertion failed\n", error); } /* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */