From ba2ea14a6a367aecfc588c2655ea77aac4ae7086 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Mon, 15 Dec 2014 09:40:25 +0000 Subject: [PATCH] Eliminate fdt_data_verify(). The verification it proceed is wrong disallowing us to encode 64-bit register numbers. Discussed with: nwhitehorn, andrew --- sys/dev/fdt/fdt_common.c | 70 ++++------------------------------------ sys/dev/fdt/fdt_common.h | 2 -- 2 files changed, 6 insertions(+), 66 deletions(-) diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 117e7de7adcc..d99fdf26dcdf 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -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); diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h index 0a79ce03baf8..3d05341dad1d 100644 --- a/sys/dev/fdt/fdt_common.h +++ b/sys/dev/fdt/fdt_common.h @@ -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);