Eliminate fdt_data_verify(). The verification it proceed is wrong

disallowing us to encode 64-bit register numbers.

Discussed with:	nwhitehorn, andrew
This commit is contained in:
Ruslan Bukin 2014-12-15 09:40:25 +00:00
parent 50a601af50
commit ba2ea14a6a
2 changed files with 6 additions and 66 deletions

View File

@ -102,10 +102,9 @@ fdt_get_range_by_busaddr(phandle_t node, u_long addr, u_long *base,
tuple_size = addr_cells + par_addr_cells + size_cells;
tuples = len / (tuple_size * sizeof(cell_t));
if (fdt_ranges_verify(ranges, tuples, par_addr_cells,
addr_cells, size_cells)) {
if (par_addr_cells > 2 || addr_cells > 2 || size_cells > 2)
return (ERANGE);
}
*base = 0;
*size = 0;
@ -173,10 +172,9 @@ fdt_get_range(phandle_t node, int range_id, u_long *base, u_long *size)
size_cells);
tuples = len / tuple_size;
if (fdt_ranges_verify(ranges, tuples, par_addr_cells,
addr_cells, size_cells)) {
if (par_addr_cells > 2 || addr_cells > 2 || size_cells > 2)
return (ERANGE);
}
*base = 0;
*size = 0;
rangesptr = &ranges[range_id];
@ -380,20 +378,6 @@ fdt_parent_addr_cells(phandle_t node)
return ((int)fdt32_to_cpu(addr_cells));
}
int
fdt_data_verify(void *data, int cells)
{
uint64_t d64;
if (cells > 1) {
d64 = fdt64_to_cpu(*((uint64_t *)data));
if (((d64 >> 32) & 0xffffffffull) != 0 || cells > 2)
return (ERANGE);
}
return (0);
}
int
fdt_pm_is_enabled(phandle_t node)
{
@ -440,62 +424,20 @@ fdt_addrsize_cells(phandle_t node, int *addr_cells, int *size_cells)
return (0);
}
int
fdt_ranges_verify(pcell_t *ranges, int tuples, int par_addr_cells,
int this_addr_cells, int this_size_cells)
{
int i, rv, ulsz;
if (par_addr_cells > 2 || this_addr_cells > 2 || this_size_cells > 2)
return (ERANGE);
/*
* This is the max size the resource manager can handle for addresses
* and sizes.
*/
ulsz = sizeof(u_long);
if (par_addr_cells <= ulsz && this_addr_cells <= ulsz &&
this_size_cells <= ulsz)
/* We can handle everything */
return (0);
rv = 0;
for (i = 0; i < tuples; i++) {
if (fdt_data_verify((void *)ranges, par_addr_cells))
goto err;
ranges += par_addr_cells;
if (fdt_data_verify((void *)ranges, this_addr_cells))
goto err;
ranges += this_addr_cells;
if (fdt_data_verify((void *)ranges, this_size_cells))
goto err;
ranges += this_size_cells;
}
return (0);
err:
debugf("using address range >%d-bit not supported\n", ulsz * 8);
return (ERANGE);
}
int
fdt_data_to_res(pcell_t *data, int addr_cells, int size_cells, u_long *start,
u_long *count)
{
/* Address portion. */
if (fdt_data_verify((void *)data, addr_cells))
if (addr_cells > 2)
return (ERANGE);
*start = fdt_data_get((void *)data, addr_cells);
data += addr_cells;
/* Size portion. */
if (fdt_data_verify((void *)data, size_cells))
if (size_cells > 2)
return (ERANGE);
*count = fdt_data_get((void *)data, size_cells);

View File

@ -79,7 +79,6 @@ extern u_char fdt_static_dtb;
int fdt_addrsize_cells(phandle_t, int *, int *);
u_long fdt_data_get(void *, int);
int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
int fdt_data_verify(void *, int);
phandle_t fdt_find_compatible(phandle_t, const char *, int);
phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
@ -94,7 +93,6 @@ int fdt_is_enabled(phandle_t);
int fdt_pm_is_enabled(phandle_t);
int fdt_is_type(phandle_t, const char *);
int fdt_parent_addr_cells(phandle_t);
int fdt_ranges_verify(pcell_t *, int, int, int, int);
int fdt_reg_to_rl(phandle_t, struct resource_list *);
int fdt_pm(phandle_t);
int fdt_get_unit(device_t);