From: Rob Herring <robh+dt@kernel.org> To: Michael Ellerman <mpe@ellerman.id.au> Cc: Mitchel Humpherys <mitchelh@codeaurora.org>, Frank Rowand <frowand.list@gmail.com>, Grant Likely <grant.likely@linaro.org>, "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, Marek Szyprowski <m.szyprowski@samsung.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, linuxppc-dev <linuxppc-dev@lists.ozlabs.org> Subject: Re: [PATCH v2] of: Check for overlap in reserved memory regions Date: Mon, 9 Nov 2015 22:41:58 -0600 [thread overview] Message-ID: <CAL_JsqLAxTF6DgwHNN94iQyds-rmchKS4Tx+8U7sSbAvGHMg9Q@mail.gmail.com> (raw) In-Reply-To: <1447129784.13889.25.camel@ellerman.id.au> On Mon, Nov 9, 2015 at 10:29 PM, Michael Ellerman <mpe@ellerman.id.au> wrote: > 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; >> +} >> + >> +static void __init __rmem_check_for_overlap(void) >> +{ >> + int i; >> + >> + if (reserved_mem_count < 2) >> + return; >> + >> + sort(reserved_mem, reserved_mem_count, sizeof(reserved_mem[0]), >> + __rmem_cmp, NULL); >> + for (i = 0; i < reserved_mem_count - 1; i++) { >> + struct reserved_mem *this, *next; >> + >> + this = &reserved_mem[i]; >> + next = &reserved_mem[i + 1]; >> + if (!(this->base && next->base)) >> + continue; >> + if (this->base + this->size > next->base) { >> + phys_addr_t this_end, next_end; >> + >> + this_end = this->base + this->size; >> + next_end = next->base + next->size; >> + WARN(1, >> + "Reserved memory: OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n", >> + this->name, &this->base, &this_end, >> + next->name, &next->base, &next_end); > > This is blowing up on some powerpc machines. > > It's too early in boot to call WARN() on these systems. I didn't realize WARN could not be used early. Good to know. > Can we turn it into a pr_err() for now? Sounds fine. > I'll send a patch? Great. Rob
WARNING: multiple messages have this Message-ID (diff)
From: Rob Herring <robh+dt@kernel.org> To: Michael Ellerman <mpe@ellerman.id.au> Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, Mitchel Humpherys <mitchelh@codeaurora.org>, linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Grant Likely <grant.likely@linaro.org>, Frank Rowand <frowand.list@gmail.com>, Marek Szyprowski <m.szyprowski@samsung.com> Subject: Re: [PATCH v2] of: Check for overlap in reserved memory regions Date: Mon, 9 Nov 2015 22:41:58 -0600 [thread overview] Message-ID: <CAL_JsqLAxTF6DgwHNN94iQyds-rmchKS4Tx+8U7sSbAvGHMg9Q@mail.gmail.com> (raw) In-Reply-To: <1447129784.13889.25.camel@ellerman.id.au> On Mon, Nov 9, 2015 at 10:29 PM, Michael Ellerman <mpe@ellerman.id.au> wrote: > 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; >> +} >> + >> +static void __init __rmem_check_for_overlap(void) >> +{ >> + int i; >> + >> + if (reserved_mem_count < 2) >> + return; >> + >> + sort(reserved_mem, reserved_mem_count, sizeof(reserved_mem[0]), >> + __rmem_cmp, NULL); >> + for (i = 0; i < reserved_mem_count - 1; i++) { >> + struct reserved_mem *this, *next; >> + >> + this = &reserved_mem[i]; >> + next = &reserved_mem[i + 1]; >> + if (!(this->base && next->base)) >> + continue; >> + if (this->base + this->size > next->base) { >> + phys_addr_t this_end, next_end; >> + >> + this_end = this->base + this->size; >> + next_end = next->base + next->size; >> + WARN(1, >> + "Reserved memory: OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n", >> + this->name, &this->base, &this_end, >> + next->name, &next->base, &next_end); > > This is blowing up on some powerpc machines. > > It's too early in boot to call WARN() on these systems. I didn't realize WARN could not be used early. Good to know. > Can we turn it into a pr_err() for now? Sounds fine. > I'll send a patch? Great. Rob _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
next prev parent reply other threads:[~2015-11-10 4:42 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-09-16 1:30 [PATCH v2] of: Check for overlap in reserved memory regions Mitchel Humpherys 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:29 ` Michael Ellerman 2015-11-10 4:41 ` Rob Herring [this message] 2015-11-10 4:41 ` Rob Herring 2015-11-10 4:57 ` Michael Ellerman 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 2015-11-12 8:06 ` Michael Ellerman
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=CAL_JsqLAxTF6DgwHNN94iQyds-rmchKS4Tx+8U7sSbAvGHMg9Q@mail.gmail.com \ --to=robh+dt@kernel.org \ --cc=devicetree@vger.kernel.org \ --cc=frowand.list@gmail.com \ --cc=grant.likely@linaro.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=m.szyprowski@samsung.com \ --cc=mitchelh@codeaurora.org \ --cc=mpe@ellerman.id.au \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.