summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-02-08 06:21:04 +0000
committermpi <mpi@openbsd.org>2015-02-08 06:21:04 +0000
commitfdd0cfd80df1fd3590cc1704a081c033b20a640c (patch)
treed4858ac8f95b98c8ce498834923b8c5cafe5d8e9
parentmd_prep_disklabel should run disklabel (for fresh disks intended to be (diff)
downloadwireguard-openbsd-fdd0cfd80df1fd3590cc1704a081c033b20a640c.tar.xz
wireguard-openbsd-fdd0cfd80df1fd3590cc1704a081c033b20a640c.zip
Do not assume that addresses passed to bus_space_map(9) are relative
to the bus base address, that's not the case with radeondrm(9) cards on G5. From miod@
-rw-r--r--sys/arch/powerpc/powerpc/bus_space.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/arch/powerpc/powerpc/bus_space.c b/sys/arch/powerpc/powerpc/bus_space.c
index e87d44c5acf..578654bddf5 100644
--- a/sys/arch/powerpc/powerpc/bus_space.c
+++ b/sys/arch/powerpc/powerpc/bus_space.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_space.c,v 1.2 2015/01/22 17:55:46 mpi Exp $ */
+/* $OpenBSD: bus_space.c,v 1.3 2015/02/08 06:21:04 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -59,7 +59,14 @@ bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
/* if bus has base of 0 fail. */
return EINVAL;
}
- bpa |= POWERPC_BUS_TAG_BASE(t);
+
+ /*
+ * The address may, or may not, be relative to the
+ * base address of this bus.
+ */
+ if (bpa < POWERPC_BUS_TAG_BASE(t))
+ bpa += POWERPC_BUS_TAG_BASE(t);
+
if ((error = extent_alloc_region(devio_ex, bpa, size, EX_NOWAIT |
(ppc_malloc_ok ? EX_MALLOCOK : 0))))
return error;
@@ -125,7 +132,12 @@ bus_space_mmap(bus_space_tag_t t, bus_addr_t bpa, off_t off, int prot,
if (POWERPC_BUS_TAG_BASE(t) == 0)
return (-1);
- bpa |= POWERPC_BUS_TAG_BASE(t);
+ /*
+ * The address may, or may not, be relative to the
+ * base address of this bus.
+ */
+ if (bpa < POWERPC_BUS_TAG_BASE(t))
+ bpa += POWERPC_BUS_TAG_BASE(t);
if (flags & BUS_SPACE_MAP_CACHEABLE)
pmapflags &= ~PMAP_NOCACHE;