Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Mar 2016 02:59:06 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r296250 - in head/sys: arm/arm arm64/arm64 mips/mips riscv/riscv sparc64/sparc64 x86/x86
Message-ID:  <201603010259.u212x6fZ097134@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Tue Mar  1 02:59:06 2016
New Revision: 296250
URL: https://svnweb.freebsd.org/changeset/base/296250

Log:
  Correct the memory rman ranges to be to BUS_SPACE_MAXADDR
  
  Summary:
  As part of the migration of rman_res_t to be typed to uintmax_t, memory ranges
  must be clamped appropriately for the bus, to prevent completely bogus addresses
  from being used.
  
  This is extracted from D4544.
  
  Reviewed By: cem
  Sponsored by:	Alex Perez/Inertial Computing
  Differential Revision: https://reviews.freebsd.org/D5134

Modified:
  head/sys/arm/arm/nexus.c
  head/sys/arm64/arm64/nexus.c
  head/sys/mips/mips/nexus.c
  head/sys/riscv/riscv/nexus.c
  head/sys/sparc64/sparc64/nexus.c
  head/sys/x86/x86/nexus.c

Modified: head/sys/arm/arm/nexus.c
==============================================================================
--- head/sys/arm/arm/nexus.c	Tue Mar  1 02:36:50 2016	(r296249)
+++ head/sys/arm/arm/nexus.c	Tue Mar  1 02:59:06 2016	(r296250)
@@ -161,10 +161,11 @@ nexus_attach(device_t dev)
 {
 
 	mem_rman.rm_start = 0;
-	mem_rman.rm_end = ~0ul;
+	mem_rman.rm_end = BUS_SPACE_MAXADDR;
 	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))
+	if (rman_init(&mem_rman) ||
+	    rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR))
 		panic("nexus_probe mem_rman");
 
 	/*

Modified: head/sys/arm64/arm64/nexus.c
==============================================================================
--- head/sys/arm64/arm64/nexus.c	Tue Mar  1 02:36:50 2016	(r296249)
+++ head/sys/arm64/arm64/nexus.c	Tue Mar  1 02:59:06 2016	(r296250)
@@ -153,13 +153,14 @@ nexus_attach(device_t dev)
 {
 
 	mem_rman.rm_start = 0;
-	mem_rman.rm_end = ~0ul;
+	mem_rman.rm_end = BUS_SPACE_MAXADDR;
 	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))
+	if (rman_init(&mem_rman) ||
+	    rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR))
 		panic("nexus_attach mem_rman");
 	irq_rman.rm_start = 0;
-	irq_rman.rm_end = ~0ul;
+	irq_rman.rm_end = ~0;
 	irq_rman.rm_type = RMAN_ARRAY;
 	irq_rman.rm_descr = "Interrupts";
 	if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0))

Modified: head/sys/mips/mips/nexus.c
==============================================================================
--- head/sys/mips/mips/nexus.c	Tue Mar  1 02:36:50 2016	(r296249)
+++ head/sys/mips/mips/nexus.c	Tue Mar  1 02:59:06 2016	(r296250)
@@ -185,11 +185,11 @@ nexus_probe(device_t dev)
 	}
 
 	mem_rman.rm_start = 0;
-	mem_rman.rm_end = ~0ul;
+	mem_rman.rm_end = BUS_SPACE_MAXADDR;
 	mem_rman.rm_type = RMAN_ARRAY;
 	mem_rman.rm_descr = "Memory addresses";
 	if (rman_init(&mem_rman) != 0 ||
-	    rman_manage_region(&mem_rman, 0, ~0) != 0) {
+	    rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR) != 0) {
 		panic("%s: mem_rman", __func__);
 	}
 

Modified: head/sys/riscv/riscv/nexus.c
==============================================================================
--- head/sys/riscv/riscv/nexus.c	Tue Mar  1 02:36:50 2016	(r296249)
+++ head/sys/riscv/riscv/nexus.c	Tue Mar  1 02:59:06 2016	(r296250)
@@ -143,13 +143,14 @@ nexus_attach(device_t dev)
 {
 
 	mem_rman.rm_start = 0;
-	mem_rman.rm_end = ~0ul;
+	mem_rman.rm_end = BUS_SPACE_MAXADDR;
 	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))
+	if (rman_init(&mem_rman) ||
+	    rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR))
 		panic("nexus_attach mem_rman");
 	irq_rman.rm_start = 0;
-	irq_rman.rm_end = ~0ul;
+	irq_rman.rm_end = ~0;
 	irq_rman.rm_type = RMAN_ARRAY;
 	irq_rman.rm_descr = "Interrupts";
 	if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0))

Modified: head/sys/sparc64/sparc64/nexus.c
==============================================================================
--- head/sys/sparc64/sparc64/nexus.c	Tue Mar  1 02:36:50 2016	(r296249)
+++ head/sys/sparc64/sparc64/nexus.c	Tue Mar  1 02:59:06 2016	(r296250)
@@ -233,7 +233,7 @@ nexus_attach(device_t dev)
 		    rman_init(&sc->sc_mem_rman) != 0 ||
 		    rman_manage_region(&sc->sc_intr_rman, 0,
 		    IV_MAX - 1) != 0 ||
-		    rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0)
+		    rman_manage_region(&sc->sc_mem_rman, 0, BUS_SPACE_MAXADDR) != 0)
 			panic("%s: failed to set up rmans.", __func__);
 	} else
 		node = ofw_bus_get_node(dev);

Modified: head/sys/x86/x86/nexus.c
==============================================================================
--- head/sys/x86/x86/nexus.c	Tue Mar  1 02:36:50 2016	(r296249)
+++ head/sys/x86/x86/nexus.c	Tue Mar  1 02:59:06 2016	(r296250)
@@ -261,11 +261,15 @@ nexus_init_resources(void)
 		panic("nexus_init_resources port_rman");
 
 	mem_rman.rm_start = 0;
-	mem_rman.rm_end = ~0ul;
+#ifndef PAE
+	mem_rman.rm_end = BUS_SPACE_MAXADDR;
+#else
+	mem_rman.rm_end = ((1ULL << cpu_maxphyaddr) - 1);
+#endif
 	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))
+	    || rman_manage_region(&mem_rman, 0, mem_rman.rm_end))
 		panic("nexus_init_resources mem_rman");
 }
 



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