From: Michael Ellerman <mpe@ellerman.id.au>
To: Mitchel Humpherys <mitchelh@codeaurora.org>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Grant Likely <grant.likely@linaro.org>,
devicetree@vger.kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] of: Check for overlap in reserved memory regions
Date: Thu, 12 Nov 2015 19:06:25 +1100 [thread overview]
Message-ID: <1447315585.31688.5.camel@ellerman.id.au> (raw)
In-Reply-To: <1442367036-15205-1-git-send-email-mitchelh@codeaurora.org>
On Tue, 2015-09-15 at 18:30 -0700, Mitchel Humpherys wrote:
> Any overlap in the reserved memory regions (those specified in the
> reserved-memory DT node) is a bug. These bugs might go undetected as
> long as the contested region isn't used simultaneously by multiple
> software agents, which makes such bugs hard to debug. Fix this by
> printing a scary warning during boot if overlap is detected.
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 726ebe792813..62f467b8ccae 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -197,12 +198,52 @@ static int __init __reserved_mem_init_node(struct reserved_mem *rmem)
> return -ENOENT;
> }
>
> +static int __init __rmem_cmp(const void *a, const void *b)
> +{
> + const struct reserved_mem *ra = a, *rb = b;
> +
> + return ra->base - rb->base;
> +}
So on further inspection it seems this is really our problem.
The reserved_mem->base values are u64, so when the unsigned result of the
substraction is converted to int we may or may not get the right value. That
means the sort fails and the reserved mem check gives false positives.
eg:
Reserved memory: OVERLAP DETECTED!
ibm,slw-image@1ffe600000 (0x0000001ffe600000--0x0000001ffe700000) overlaps with ibm,firmware-allocs-memory@1000000000 (0x0000001000000000--0x0000001000dc0200)
Note there is no overlap:
0x0000001ffe600000--0x0000001ffe700000
vs
0x0000001000000000--0x0000001000dc0200
cheers
prev parent reply other threads:[~2015-11-12 8:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 1:30 Mitchel Humpherys
2015-10-13 20:13 ` Rob Herring
2015-11-10 4:29 ` Michael Ellerman
2015-11-10 4:41 ` Rob Herring
2015-11-10 4:57 ` Michael Ellerman
2015-11-12 2:19 ` Michael Ellerman
2015-12-04 17:27 ` Mitchel Humpherys
2015-11-12 8:06 ` Michael Ellerman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447315585.31688.5.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=grant.likely@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mitchelh@codeaurora.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®