svn commit: r223500 - in stable/8/sys: arm/arm ia64/ia64 kern mips/mips mips/rmi x86/x86

John Baldwin jhb at FreeBSD.org
Fri Jun 24 13:41:47 UTC 2011


Author: jhb
Date: Fri Jun 24 13:41:46 2011
New Revision: 223500
URL: http://svn.freebsd.org/changeset/base/223500

Log:
  MFC 221218:
  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.

Modified:
  stable/8/sys/arm/arm/nexus.c
  stable/8/sys/ia64/ia64/nexus.c
  stable/8/sys/kern/subr_rman.c
  stable/8/sys/mips/mips/mainbus.c
  stable/8/sys/mips/mips/nexus.c
  stable/8/sys/mips/rmi/pcibus.c   (contents, props changed)
  stable/8/sys/mips/rmi/xlr_pci.c
  stable/8/sys/x86/x86/nexus.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/arm/arm/nexus.c
==============================================================================
--- stable/8/sys/arm/arm/nexus.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/arm/arm/nexus.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -110,10 +110,10 @@ nexus_probe(device_t dev)
 	device_quiet(dev);	/* suppress attach message for neatness */
 
 	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");
 
 	return (0);

Modified: stable/8/sys/ia64/ia64/nexus.c
==============================================================================
--- stable/8/sys/ia64/ia64/nexus.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/ia64/ia64/nexus.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -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)

Modified: stable/8/sys/kern/subr_rman.c
==============================================================================
--- stable/8/sys/kern/subr_rman.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/kern/subr_rman.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -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_lo
 
 	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;

Modified: stable/8/sys/mips/mips/mainbus.c
==============================================================================
--- stable/8/sys/mips/mips/mainbus.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/mips/mips/mainbus.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -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))

Modified: stable/8/sys/mips/mips/nexus.c
==============================================================================
--- stable/8/sys/mips/mips/nexus.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/mips/mips/nexus.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -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 ||

Modified: stable/8/sys/mips/rmi/pcibus.c
==============================================================================
--- stable/8/sys/mips/rmi/pcibus.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/mips/rmi/pcibus.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/pci/pcibus.c,v 1.36 2005/01/05 20:05:52 imp Exp $");
+__FBSDID("$FreeBSD$");
 
 #include "opt_isa.h"
 
@@ -229,7 +229,7 @@ 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)
@@ -237,7 +237,7 @@ 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)

Modified: stable/8/sys/mips/rmi/xlr_pci.c
==============================================================================
--- stable/8/sys/mips/rmi/xlr_pci.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/mips/rmi/xlr_pci.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -133,7 +133,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)
@@ -141,7 +141,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)

Modified: stable/8/sys/x86/x86/nexus.c
==============================================================================
--- stable/8/sys/x86/x86/nexus.c	Fri Jun 24 12:55:16 2011	(r223499)
+++ stable/8/sys/x86/x86/nexus.c	Fri Jun 24 13:41:46 2011	(r223500)
@@ -266,7 +266,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)


More information about the svn-src-stable-8 mailing list