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
This commit is contained in:
jhibbits 2016-03-01 02:59:06 +00:00
parent 68514f02c5
commit 23e52c3512
6 changed files with 20 additions and 13 deletions

View File

@ -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");
/*

View File

@ -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))

View File

@ -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__);
}

View File

@ -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))

View File

@ -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);

View File

@ -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");
}