summaryrefslogtreecommitdiffstats
path: root/sys/sparc64
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2005-05-21 20:17:01 +0000
committermarius <marius@FreeBSD.org>2005-05-21 20:17:01 +0000
commit13915d800856c36aa446d054c82e2fa56646b87b (patch)
treeb6b562e9e14e4418f0f7514043a7433e9aabfb44 /sys/sparc64
parent04974fa76eb1957d466d8fa77dcd23d008b19399 (diff)
downloadFreeBSD-src-13915d800856c36aa446d054c82e2fa56646b87b.zip
FreeBSD-src-13915d800856c36aa446d054c82e2fa56646b87b.tar.gz
- Make sure that the OFW address properties that are going to be decode
consist of the expected number of address and size cells (we can't use dynamic arrays here because at the point in the boot process when this code is used malloc() doesn't work, yet). This fixes a Fast Data Access MMU Miss when uart(4) (erroneously) calls OF_decode_addr() to decode the address of PS/2 keyboards. PS/2 keyboards use a different and also undocumented scheme at the first parent node than mapping at 'ranges' properties. It's however not worth implementing that other scheme and actually also fits atkbdc(4) better to just start at the first parent node of PS/2 keyboards which is the 8042 controller (I have atkbdc(4) working that way). - Use FBSDID. MFC after: 1 month
Diffstat (limited to 'sys/sparc64')
-rw-r--r--sys/sparc64/sparc64/ofw_machdep.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/sparc64/sparc64/ofw_machdep.c b/sys/sparc64/sparc64/ofw_machdep.c
index 391af4c..016b432 100644
--- a/sys/sparc64/sparc64/ofw_machdep.c
+++ b/sys/sparc64/sparc64/ofw_machdep.c
@@ -22,9 +22,10 @@
* 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$
*/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
/*
* Some Open Firmware helper functions that are likely machine dependent.
@@ -133,7 +134,7 @@ OF_decode_addr(phandle_t node, int bank, int *space, bus_addr_t *addr)
addrc = 2;
if (OF_getprop(bus, "#size-cells", &szc, sizeof(szc)) == -1)
szc = 1;
- if (szc > 2)
+ if (addrc < 2 || addrc > 3 || szc < 1 || szc > 2)
return (ENXIO);
if (strcmp(name, "pci") == 0) {
if (addrc > 3)
@@ -178,7 +179,7 @@ OF_decode_addr(phandle_t node, int bank, int *space, bus_addr_t *addr)
if (OF_getprop(pbus, "#address-cells", &paddrc,
sizeof(paddrc)) == -1)
paddrc = 2;
- if (paddrc > 3)
+ if (paddrc < 2 || paddrc > 3)
return (ENXIO);
nbank = OF_getprop(bus, "ranges", &banks, sizeof(banks));
if (nbank == -1) {
@@ -191,7 +192,7 @@ OF_decode_addr(phandle_t node, int bank, int *space, bus_addr_t *addr)
if (OF_getprop(bus, "#size-cells", &szc,
sizeof(szc)) == -1)
szc = 1;
- if (szc > 2)
+ if (szc < 1 || szc > 2)
return (ENXIO);
}
nbank /= sizeof(banks[0]) * (addrc + paddrc + szc);
OpenPOWER on IntegriCloud