Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Mar 2008 19:31:20 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        sobomax@FreeBSD.org
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!
Message-ID:  <20080304.193120.-625041952.imp@bsdimp.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080304.193120.-625041952.imp>