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");
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to