From: "Suzuki K. Poulose" <Suzuki.Poulose-5wv7dgnIgG8@public.gmane.org>
To: Ard Biesheuvel
<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Mark Rutland <Mark.Rutland-5wv7dgnIgG8@public.gmane.org>,
"rob.herring-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<rob.herring-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH v2 1/2] of/fdt: export fdt blob as /sys/firmware/fdt
Date: Wed, 12 Nov 2014 10:42:05 +0000 [thread overview]
Message-ID: <5463397D.7060506@arm.com> (raw)
In-Reply-To: <1415645222-14909-2-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On 10/11/14 18:47, Ard Biesheuvel wrote:
> Create a new /sys entry '/sys/firmware/fdt' to export the FDT blob
> that was passed to the kernel by the bootloader. This allows userland
> applications such as kexec to access the raw binary. The blob needs to
> be preserved as early as possible by calling preserve_fdt().
>
> The fact that this node does not reside under /sys/firmware/device-tree
> is deliberate: FDT is also used on arm64 UEFI/ACPI systems to
> communicate just the UEFI and ACPI entry points, but the FDT is never
> unflattened and used to configure the system.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> drivers/of/fdt.c | 34 ++++++++++++++++++++++++++++++++++
> include/linux/of_fdt.h | 2 ++
> 2 files changed, 36 insertions(+)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1ffca8b34ea..e9ee3d5f7ea4 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -22,6 +22,7 @@
> #include <linux/libfdt.h>
> #include <linux/debugfs.h>
> #include <linux/serial_core.h>
> +#include <linux/sysfs.h>
>
> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */
> #include <asm/page.h>
> @@ -1103,4 +1104,37 @@ static int __init of_flat_dt_debugfs_export_fdt(void)
> module_init(of_flat_dt_debugfs_export_fdt);
> #endif
>
> +static u8 *raw_fdt_copy;
> +
> +void __init preserve_fdt(void)
> +{
> + u32 fdt_size;
> +
> + fdt_size = fdt_totalsize(initial_boot_params);
> + raw_fdt_copy = memcpy(__va(memblock_alloc(fdt_size, PAGE_SIZE)),
> + initial_boot_params, fdt_size);
> +}
> +
> +#ifdef CONFIG_SYSFS
> +static ssize_t of_fdt_raw_read(struct file *filp, struct kobject *kobj,
> + struct bin_attribute *bin_attr,
> + char *buf, loff_t off, size_t count)
> +{
> + memcpy(buf, raw_fdt_copy + off, count);
Should we check for the off+count, not to exceed the fdt_size that we
actually copied ?
Thanks
Suzuki
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-11-12 10:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-10 18:47 [PATCH v2 0/2] preserve FDT blob and present as /sys/firmware/fdt Ard Biesheuvel
[not found] ` <1415645222-14909-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-11-10 18:47 ` [PATCH v2 1/2] of/fdt: export fdt blob " Ard Biesheuvel
[not found] ` <1415645222-14909-2-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-11-11 14:42 ` Grant Likely
[not found] ` <20141111144221.5FCDAC416AF-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-11-11 14:44 ` Ard Biesheuvel
2014-11-11 16:25 ` Rob Herring
[not found] ` <CAL_JsqKeG1dWrMZydCN119V3++WKXqsjMm1bG7Fodhf3O8owpw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-11 20:08 ` Grant Likely
[not found] ` <CACxGe6tsLr52ZLww2JfwHFHajHW+f6nbYJPyWXmZJg3coKmMCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-11 20:34 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-UOPMaGQ+eRu8TX4DX_AN93JHt9dFHSaWs9+UB3UhdAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-12 11:45 ` Grant Likely
[not found] ` <CACxGe6sN6dObiOnbhYM4Ltdn0BU_KTESuefvxh3odm1BbcUVbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-12 11:51 ` Ard Biesheuvel
[not found] ` <CAKv+Gu9BgH8DiU=z-A5NDcCSwamJ84x3s95G=RGNoO9ostmTwg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-12 12:01 ` Grant Likely
2014-11-12 12:08 ` Ard Biesheuvel
[not found] ` <CAKv+Gu8wenvVa3=35pXTJkbZT+cwpAUfs6RdcBtWGyOyzXcupg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-12 12:10 ` Grant Likely
2014-11-12 10:42 ` Suzuki K. Poulose [this message]
2014-11-10 18:47 ` [PATCH v2 2/2] arm64: fdt: call preserve_fdt() before unflattening it Ard Biesheuvel
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=5463397D.7060506@arm.com \
--to=suzuki.poulose-5wv7dgnigg8@public.gmane.org \
--cc=Mark.Rutland-5wv7dgnIgG8@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=geoff.levand-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=rob.herring-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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).