summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-04-29 18:41:21 +0000
committerjhb <jhb@FreeBSD.org>2011-04-29 18:41:21 +0000
commit08955ceac0e6a5e070d655c0f47e170747a075d7 (patch)
treef321d6b25b24b3e15d314a828cb978d9b0cadfa4
parent67e72142a1251ce0ac4d06ca82beb414ff6ae9f7 (diff)
downloadFreeBSD-src-08955ceac0e6a5e070d655c0f47e170747a075d7.zip
FreeBSD-src-08955ceac0e6a5e070d655c0f47e170747a075d7.tar.gz
Change rman_manage_region() to actually honor the rm_start and rm_end
constraints on the rman and reject attempts to manage a region that is out of range. - Fix various places that set rm_end incorrectly (to ~0 or ~0u instead of ~0ul). - To preserve existing behavior, change rman_init() to set rm_start and rm_end to allow managing the full range (0 to ~0ul) if they are not set by the caller when rman_init() is called.
-rw-r--r--sys/arm/arm/nexus.c4
-rw-r--r--sys/dev/fdt/fdtbus.c2
-rw-r--r--sys/ia64/ia64/nexus.c2
-rw-r--r--sys/kern/subr_rman.c4
-rw-r--r--sys/mips/mips/mainbus.c2
-rw-r--r--sys/mips/mips/nexus.c2
-rw-r--r--sys/mips/rmi/xlr_pci.c4
-rw-r--r--sys/x86/x86/nexus.c2
8 files changed, 13 insertions, 9 deletions
diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index 4efca14..bbde900 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -138,10 +138,10 @@ nexus_attach(device_t dev)
{
mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
+ mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
- if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0u))
+ if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0))
panic("nexus_probe mem_rman");
/*
diff --git a/sys/dev/fdt/fdtbus.c b/sys/dev/fdt/fdtbus.c
index 96d9a6e..86a9d17 100644
--- a/sys/dev/fdt/fdtbus.c
+++ b/sys/dev/fdt/fdtbus.c
@@ -206,7 +206,7 @@ fdtbus_attach(device_t dev)
* Mem-mapped I/O space rman.
*/
start = 0;
- end = ~0u;
+ end = ~0ul;
sc->sc_mem.rm_start = start;
sc->sc_mem.rm_end = end;
sc->sc_mem.rm_type = RMAN_ARRAY;
diff --git a/sys/ia64/ia64/nexus.c b/sys/ia64/ia64/nexus.c
index 43d0632..8e71b1e 100644
--- a/sys/ia64/ia64/nexus.c
+++ b/sys/ia64/ia64/nexus.c
@@ -174,7 +174,7 @@ nexus_probe(device_t dev)
panic("nexus_probe port_rman");
mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
+ mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman)
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index cfa4983..4352278 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -138,6 +138,8 @@ rman_init(struct rman *rm)
mtx_init(&rman_mtx, "rman head", NULL, MTX_DEF);
}
+ if (rm->rm_start == 0 && rm->rm_end == 0)
+ rm->rm_end = ~0ul;
if (rm->rm_type == RMAN_UNINIT)
panic("rman_init");
if (rm->rm_type == RMAN_GAUGE)
@@ -162,6 +164,8 @@ rman_manage_region(struct rman *rm, u_long start, u_long end)
DPRINTF(("rman_manage_region: <%s> request: start %#lx, end %#lx\n",
rm->rm_descr, start, end));
+ if (start < rm->rm_start || end > rm->rm_end)
+ return EINVAL;
r = int_alloc_resource(M_NOWAIT);
if (r == NULL)
return ENOMEM;
diff --git a/sys/mips/mips/mainbus.c b/sys/mips/mips/mainbus.c
index 587b409..b68b74b 100644
--- a/sys/mips/mips/mainbus.c
+++ b/sys/mips/mips/mainbus.c
@@ -146,7 +146,7 @@ mainbus_probe(device_t dev)
panic("mainbus_probe port_rman");
mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
+ mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0))
diff --git a/sys/mips/mips/nexus.c b/sys/mips/mips/nexus.c
index 2274466..b51357d 100644
--- a/sys/mips/mips/nexus.c
+++ b/sys/mips/mips/nexus.c
@@ -151,7 +151,7 @@ nexus_probe(device_t dev)
}
mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
+ mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "Memory addresses";
if (rman_init(&mem_rman) != 0 ||
diff --git a/sys/mips/rmi/xlr_pci.c b/sys/mips/rmi/xlr_pci.c
index 7532816..29db1b6 100644
--- a/sys/mips/rmi/xlr_pci.c
+++ b/sys/mips/rmi/xlr_pci.c
@@ -126,7 +126,7 @@ xlr_pci_init_resources(void)
panic("pci_init_resources irq_rman");
port_rman.rm_start = 0;
- port_rman.rm_end = ~0u;
+ port_rman.rm_end = ~0ul;
port_rman.rm_type = RMAN_ARRAY;
port_rman.rm_descr = "I/O ports";
if (rman_init(&port_rman)
@@ -134,7 +134,7 @@ xlr_pci_init_resources(void)
panic("pci_init_resources port_rman");
mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
+ mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory";
if (rman_init(&mem_rman)
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
index fa2aded..3564078 100644
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -256,7 +256,7 @@ nexus_init_resources(void)
panic("nexus_init_resources port_rman");
mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
+ mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman)
OpenPOWER on IntegriCloud