linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Quentin Perret <qperret@google.com>
Cc: robh+dt@kernel.org, drinkcat@chromium.org,
	devicetree@vger.kernel.org, f.fainelli@gmail.com,
	swboyd@chromium.org, karahmed@amazon.de, kernel-team@android.com,
	frowand.list@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] of/fdt: Make sure no-map does not remove already reserved regions
Date: Fri, 15 Jan 2021 11:30:15 -0600	[thread overview]
Message-ID: <20210115173015.GA1496104@robh.at.kernel.org> (raw)
In-Reply-To: <20210115114544.1830068-3-qperret@google.com>

On Fri, 15 Jan 2021 11:45:44 +0000, Quentin Perret wrote:
> From: Nicolas Boichat <drinkcat@chromium.org>
> 
> If the device tree is incorrectly configured, and attempts to
> define a "no-map" reserved memory that overlaps with the kernel
> data/code, the kernel would crash quickly after boot, with no
> obvious clue about the nature of the issue.
> 
> For example, this would happen if we have the kernel mapped at
> these addresses (from /proc/iomem):
> 40000000-41ffffff : System RAM
>   40080000-40dfffff : Kernel code
>   40e00000-411fffff : reserved
>   41200000-413e0fff : Kernel data
> 
> And we declare a no-map shared-dma-pool region at a fixed address
> within that range:
> mem_reserved: mem_region {
> 	compatible = "shared-dma-pool";
> 	reg = <0 0x40000000 0 0x01A00000>;
> 	no-map;
> };
> 
> To fix this, when removing memory regions at early boot (which is
> what "no-map" regions do), we need to make sure that the memory
> is not already reserved. If we do, __reserved_mem_reserve_reg
> will throw an error:
> [    0.000000] OF: fdt: Reserved memory: failed to reserve memory
>    for node 'mem_region': base 0x0000000040000000, size 26 MiB
> and the code that will try to use the region should also fail,
> later on.
> 
> We do not do anything for non-"no-map" regions, as memblock
> explicitly allows reserved regions to overlap, and the commit
> that this fixes removed the check for that precise reason.
> 
> [ qperret: fixed conflicts caused by the usage of memblock_mark_nomap ]
> 
> Fixes: 094cb98179f19b7 ("of/fdt: memblock_reserve /memreserve/ regions in the case of partial overlap")
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> Signed-off-by: Quentin Perret <qperret@google.com>
> ---
>  drivers/of/fdt.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 

Applied, thanks!

  reply	other threads:[~2021-01-15 17:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 11:45 [PATCH 0/2] fdt: A couple of no-map fixes Quentin Perret
2021-01-15 11:45 ` [PATCH 1/2] fdt: Properly handle "no-map" field in the memory region Quentin Perret
2021-01-15 17:29   ` Rob Herring
2021-01-15 11:45 ` [PATCH 2/2] of/fdt: Make sure no-map does not remove already reserved regions Quentin Perret
2021-01-15 17:30   ` Rob Herring [this message]
2021-01-16  0:30     ` Nicolas Boichat

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=20210115173015.GA1496104@robh.at.kernel.org \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@chromium.org \
    --cc=f.fainelli@gmail.com \
    --cc=frowand.list@gmail.com \
    --cc=karahmed@amazon.de \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qperret@google.com \
    --cc=robh+dt@kernel.org \
    --cc=swboyd@chromium.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;
as well as URLs for NNTP newsgroup(s).