[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1447129784.13889.25.camel@ellerman.id.au>
Date: Tue, 10 Nov 2015 15:29:44 +1100
From: Michael Ellerman <mpe@...erman.id.au>
To: Mitchel Humpherys <mitchelh@...eaurora.org>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
Grant Likely <grant.likely@...aro.org>,
devicetree@...r.kernel.org,
Marek Szyprowski <m.szyprowski@...sung.com>
Cc: linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v2] of: Check for overlap in reserved memory regions
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.
Can we turn it into a pr_err() for now?
I'll send a patch?
cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists