From owner-freebsd-current@FreeBSD.ORG Wed Mar 5 02:31:25 2008 Return-Path: Delivered-To: current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57E50106566C; Wed, 5 Mar 2008 02:31:25 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id C166F8FC12; Wed, 5 Mar 2008 02:31:24 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m252Up7v078306; Tue, 4 Mar 2008 19:30:51 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 04 Mar 2008 19:31:20 -0700 (MST) Message-Id: <20080304.193120.-625041952.imp@bsdimp.com> To: sobomax@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <47CDF0FE.9040405@FreeBSD.org> References: <57AF36D8-0F83-4DF8-BEAA-CF3B59EAA361@rabson.org> <20080304.090741.-1631526462.imp@bsdimp.com> <47CDF0FE.9040405@FreeBSD.org> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: gnn@FreeBSD.org, xcllnt@mac.com, current@FreeBSD.org, re@FreeBSD.org Subject: Re: IPSEC/crypto is broken in FreeBSD/powerpc 7.0-RELEASE! X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2008 02:31:25 -0000 OK. Digging deeper into this problem shows that sparc64 also appears to do the same things to the nexus bus children that powerpc does. There may be other nexus devices that do this, and rewriting them to conform to the x86 conventions would take a little bit of effort. I'm starting to think that the architecturally clean way to solve this issue is to allow children to ask if they have a fixed devclass or a wildcard one in newbus. This is easy to implement, but as I typed this up, something inside me rebelled. In this scenario, the newbus would grow a new function device_is_wildcard() that drivers could call. The other way to fix this is to return a better value from the probe routine for those devices that attach to the nexus. A quick grep of the tree suggests that opencrypto is the only MI driver that uses this trick. There are a few MD drivers that use it as well, but they are all well controlled. Here's a quick hack. If you want to test this out without changing newbus, change the cryptosoft.c probe routine to return (BUS_PROBE_HOOVER - 1) rather than zero. Comments? Warner Index: sys/bus.h =================================================================== RCS file: /cache/ncvs/src/sys/sys/bus.h,v retrieving revision 1.79 diff -u -r1.79 bus.h --- sys/bus.h 27 Jan 2008 16:06:37 -0000 1.79 +++ sys/bus.h 5 Mar 2008 02:28:17 -0000 @@ -494,7 +494,10 @@ * is for drivers that wish to have a generic form and a specialized form, * like is done with the pci bus and the acpi pci bus. BUS_PROBE_HOOVER is * for those busses that implement a generic device place-holder for devices on - * the bus that have no more specific driver for them (aka ugen). + * the bus that have no more specific river for them (aka ugen). + * BUS_PROBE_NOWILDCARD or lower means that the device isn't really bidding + * for a device node, but accepts only devices that its parent has told it + * use this driver. */ #define BUS_PROBE_SPECIFIC 0 /* Only I can use this device */ #define BUS_PROBE_VENDOR (-10) /* Vendor supplied driver */ @@ -502,6 +505,7 @@ #define BUS_PROBE_LOW_PRIORITY (-40) /* Older, less desirable drivers */ #define BUS_PROBE_GENERIC (-100) /* generic driver for dev */ #define BUS_PROBE_HOOVER (-500) /* Generic dev for all devs on bus */ +#define BUS_PROBE_NOWILDCARD (-2000000000) /* No wildcard device matches */ /** * Shorthand for constructing method tables. Index: kern/subr_bus.c =================================================================== RCS file: /cache/ncvs/src/sys/kern/subr_bus.c,v retrieving revision 1.204 diff -u -r1.204 subr_bus.c --- kern/subr_bus.c 27 Jan 2008 16:06:37 -0000 1.204 +++ kern/subr_bus.c 5 Mar 2008 02:27:30 -0000 @@ -1777,6 +1777,14 @@ * of pri for the first match. */ if (best == NULL || result > pri) { + /* + * Probes that return BUS_PROBE_NOWILDCARD + * or lower only match when they are set + * in stone by the parent bus. + */ + if (result <= BUS_PROBE_NOWILDCARD && + child->flags & DF_WILDCARD) + continue; best = dl; pri = result; continue; Index: opencrypto/cryptosoft.c =================================================================== RCS file: /cache/ncvs/src/sys/opencrypto/cryptosoft.c,v retrieving revision 1.19 diff -u -r1.19 cryptosoft.c --- opencrypto/cryptosoft.c 9 May 2007 19:37:02 -0000 1.19 +++ opencrypto/cryptosoft.c 5 Mar 2008 02:22:28 -0000 @@ -989,7 +989,7 @@ swcr_probe(device_t dev) { device_set_desc(dev, "software crypto"); - return (0); + return (BUS_PROBE_NOWILDCARD); } static int