From: Ley Foon Tan <ley.foon.tan@intel.com>
To: Tobias Klauser <tklauser@distanz.ch>, nios2-dev@lists.rocketboards.org
Cc: Guenter Roeck <linux@roeck-us.net>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
"lftan.linux@gmail.com" <lftan.linux@gmail.com>
Subject: Re: [PATCH] nios2: reserve boot memory for device tree
Date: Mon, 03 Apr 2017 06:19:21 -0700 [thread overview]
Message-ID: <1491225561.3531.4.camel@intel.com> (raw)
In-Reply-To: <20170331094059.21394-1-tklauser@distanz.ch>
On Fri, 2017-03-31 at 11:40 +0200, Tobias Klauser wrote:
> Make sure to reserve the boot memory for the flattened device tree.
> Otherwise it might get overwritten, e.g. when initial_boot_params is
> copied, leading to a corrupted FDT and a boot hang/crash:
>
> bootconsole [early0] enabled
> Early console on uart16650 initialized at 0xf8001600
> OF: fdt: Error -11 processing FDT
> Kernel panic - not syncing: setup_cpuinfo: No CPU found in
> devicetree!
>
> ---[ end Kernel panic - not syncing: setup_cpuinfo: No CPU found in
> devicetree!
>
> Guenter Roeck says:
>
> >
> > I think I found the problem. In unflatten_and_copy_device_tree(),
> > with added
> > debug information:
> >
> > OF: fdt: initial_boot_params=c861e400, dt=c861f000 size=28874
> > (0x70ca)
> >
> > ... and then initial_boot_params is copied to dt, which results in
> > corrupted
> > fdt since the memory overlaps. Looks like the initial_boot_params
> > memory
> > is not reserved and (re-)allocated by
> > early_init_dt_alloc_memory_arch().
> Cc: stable@vger.kernel.org
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Reference: http://lkml.kernel.org/r/20170226210338.GA19476@roeck-us.n
> et
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Ley Foon Tan <ley.foon.tan@intel.com>
Thanks for the fix. Will add this for 4.11.
Regards
Ley Foon
> ---
> arch/nios2/kernel/prom.c | 7 +++++++
> arch/nios2/kernel/setup.c | 3 +++
> 2 files changed, 10 insertions(+)
>
> diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c
> index 367c5426157b..3901b80d4420 100644
> --- a/arch/nios2/kernel/prom.c
> +++ b/arch/nios2/kernel/prom.c
> @@ -48,6 +48,13 @@ void * __init early_init_dt_alloc_memory_arch(u64
> size, u64 align)
> return alloc_bootmem_align(size, align);
> }
>
> +int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
> phys_addr_t size,
> + bool nomap)
> +{
> + reserve_bootmem(base, size, BOOTMEM_DEFAULT);
> + return 0;
> +}
> +
> void __init early_init_devtree(void *params)
> {
> __be32 *dtb = (u32 *)__dtb_start;
> diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
> index 6e57ffa5db27..6044d9be28b4 100644
> --- a/arch/nios2/kernel/setup.c
> +++ b/arch/nios2/kernel/setup.c
> @@ -201,6 +201,9 @@ void __init setup_arch(char **cmdline_p)
> }
> #endif /* CONFIG_BLK_DEV_INITRD */
>
> + early_init_fdt_reserve_self();
> + early_init_fdt_scan_reserved_mem();
> +
> unflatten_and_copy_device_tree();
>
> setup_cpuinfo();
> --
> 2.12.2.399.g034667a45805
>
>
>
> ________________________________
>
> Confidentiality Notice.
> This message may contain information that is confidential or
> otherwise protected from disclosure. If you are not the intended
> recipient, you are hereby notified that any use, disclosure,
> dissemination, distribution, or copying of this message, or any
> attachments, is strictly prohibited. If you have received this
> message in error, please advise the sender by reply e-mail, and
> delete the message and any attachments. Thank you.
prev parent reply other threads:[~2017-04-03 5:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 9:40 [PATCH] nios2: reserve boot memory for device tree Tobias Klauser
2017-04-03 13:19 ` Ley Foon Tan [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=1491225561.3531.4.camel@intel.com \
--to=ley.foon.tan@intel.com \
--cc=lftan.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nios2-dev@lists.rocketboards.org \
--cc=stable@vger.kernel.org \
--cc=tklauser@distanz.ch \
/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 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.