Thread (4 messages) flat view 4 messages, 4 authors, 2015-12-06

Re: [PATCH] of: Fix comparison of reserved memory regions

From: Michael Ellerman <hidden>
Date: 2015-12-05 11:44:06
Also in: linuxppc-dev, lkml


On 5 December 2015 04:07:39 GMT+11:00, Mitchel Humpherys [off-list ref] wrote:
On Wed, Nov 18 2015 at 09:46:38 PM, Michael Ellerman
[off-list ref] wrote:
quoted
In order to check for overlapping reserved memory regions, we first
need
quoted
to sort the array of memory regions. This is implemented using
sort(),
quoted
and a custom comparison function __rmem_cmp().

Unfortunatley __rmem_cmp() doesn't work in all cases. Because the two
base values are phys_addr_t, they may be u64 on some platforms, in
which
quoted
case subtracting one from the other and then (implicitly) casting to
int
quoted
does not give us the -ve/0/+ve value we need.

This leads to incorrect reports about overlaps, eg:

  ibm,slw-image@1ffe600000 (0x0000001ffe600000--0x0000001ffe700000)
overlaps with
quoted
  ibm,firmware-allocs-memory@1000000000
(0x0000001000000000--0x0000001000dc0200)
quoted
Fix it by just doing the standard double if and return 0 logic.

Fixes: ae1add247bf8 ("of: Check for overlap in reserved memory
regions")
quoted
Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>
---
 drivers/of/of_reserved_mem.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Woops, thanks.

Tested-by: Mitchel Humpherys <redacted>
Thanks for testing.

Rob, can we get this merged for 4.4 please?

cheers 

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help