Date: Wed, 27 Jan 2016 17:33:32 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294927 - head/sys/dev/ofw Message-ID: <201601271733.u0RHXWUH032179@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andrew Date: Wed Jan 27 17:33:31 2016 New Revision: 294927 URL: https://svnweb.freebsd.org/changeset/base/294927 Log: When finding the physical address of a device allow intermediate addresses to be 64-bit on 32-bit architectures. It is not uncommon for device trees to use the upper 32-bits to store what effectively is an index into the parent ranges property. In this case, when running with a 32-bit bus_addr_t and bus_size_t, we would previously truncate the address, this may then incorrectly match the wrong range, and return the wrong address. Tested by: bz (earlier version) Modified: head/sys/dev/ofw/ofw_subr.c Modified: head/sys/dev/ofw/ofw_subr.c ============================================================================== --- head/sys/dev/ofw/ofw_subr.c Wed Jan 27 16:45:23 2016 (r294926) +++ head/sys/dev/ofw/ofw_subr.c Wed Jan 27 17:33:31 2016 (r294927) @@ -75,8 +75,8 @@ ofw_reg_to_paddr(phandle_t dev, int regn bus_size_t *psize, pcell_t *ppci_hi) { pcell_t cell[32], pci_hi; - bus_addr_t addr, raddr, baddr; - bus_size_t size, rsize; + uint64_t addr, raddr, baddr; + uint64_t size, rsize; uint32_t c, nbridge, naddr, nsize; phandle_t bridge, parent; u_int spc, rspc; @@ -167,6 +167,11 @@ ofw_reg_to_paddr(phandle_t dev, int regn get_addr_props(bridge, &naddr, &nsize, &pci); } + KASSERT(addr <= BUS_SPACE_MAXADDR, + ("Bus sddress is too large: %jx", (intmax_t)addr)); + KASSERT(size <= BUS_SPACE_MAXSIZE, + ("Bus size is too large: %jx", (intmax_t)addr)); + *paddr = addr; *psize = size; if (ppci_hi != NULL)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601271733.u0RHXWUH032179>