From: geoff@infradead.org (Geoff Levand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1 2/4] kexec: Add common device tree routines
Date: Wed, 27 Jul 2016 11:11:47 -0700 [thread overview]
Message-ID: <1469643107.2889.65.camel@infradead.org> (raw)
In-Reply-To: <20160722071924.GQ20774@linaro.org>
Hi,
On Fri, 2016-07-22 at 16:19 +0900, AKASHI Takahiro wrote:
> On Tue, Jul 19, 2016 at 11:28:13PM +0000, Geoff Levand wrote:
> > --- /dev/null
> > +++ b/kexec/dt-ops.c
> > +int dtb_set_property(char **dtb, off_t *dtb_size, const char *node,
> > +> > > > const char *prop, const void *value, int value_len)
> > +{
> > +> > > > int result;
> > +> > > > int nodeoffset;
> > +> > > > void *new_dtb;
> > +> > > > int new_size;
> > +
> > +> > > > value_len = FDT_TAGALIGN(value_len);
> > +
> > +> > > > new_size = FDT_TAGALIGN(*dtb_size + fdt_node_len(node)
> > +> > > > > > + fdt_prop_len(prop, value_len));
>
> As James pointed out before, this will increase the size of dtb
> if kexec is executed repeatedly.
I will look into this later, as it will take some time to
do, and I don't think it should hold up merge of the arm64
support.
> > +> > > > new_dtb = malloc(new_size);
> > +
> > +> > > > if (!new_dtb) {
> > +> > > > > > dbgprintf("%s: malloc failed\n", __func__);
> > +> > > > > > return -ENOMEM;
> > +> > > > }
> > +
> > +> > > > result = fdt_open_into(*dtb, new_dtb, new_size);
> > +
> > +> > > > if (result) {
> > +> > > > > > dbgprintf("%s: fdt_open_into failed: %s\n", __func__,
> > +> > > > > > > > fdt_strerror(result));
> > +> > > > > > goto on_error;
> > +> > > > }
> > +
> > +> > > > nodeoffset = fdt_path_offset(new_dtb, node);
> > +> >
> > +> > > > if (nodeoffset == -FDT_ERR_NOTFOUND) {
> > +> > > > > > result = fdt_add_subnode(new_dtb, nodeoffset, node);
> > +
> > +> > > > > > if (result) {
> > +> > > > > > > > dbgprintf("%s: fdt_add_subnode failed: %s\n", __func__,
> > +> > > > > > > > > > fdt_strerror(result));
> > +> > > > > > > > goto on_error;
> > +> > > > > > }
> > +> > > > } else if (nodeoffset < 0) {
> > +> > > > > > dbgprintf("%s: fdt_path_offset failed: %s\n", __func__,
> > +> > > > > > > > fdt_strerror(nodeoffset));
> > +> > > > > > goto on_error;
> > +> > > > }
> > +
> > +> > > > result = fdt_setprop(new_dtb, nodeoffset, prop, value, value_len);
> > +
> > +> > > > if (result) {
> > +> > > > > > dbgprintf("%s: fdt_setprop failed: %s\n", __func__,
> > +> > > > > > > > fdt_strerror(result));
> > +> > > > > > goto on_error;
> > +> > > > }
> > +
> > +> > > > /*
> > +> > > > * Can't call free on dtb since dtb may have been mmaped by
> > +> > > > * slurp_file().
> > +> > > > */
> > +
> > +> > > > *dtb = new_dtb;
> > +> > > > *dtb_size = new_size;
>
> So you might better call fdt_pack(), which will set "totalsize" of
> the blob to an appropriate value.
I fixed this. It is in my master branch now, and will post with v3.
Thanks for the review.
-Geoff
next prev parent reply other threads:[~2016-07-27 18:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 23:28 [PATCH v1 0/4] arm64 kexec-tools patches Geoff Levand
2016-07-19 23:28 ` [PATCH v1 1/4] kexec: (bugfix) calc correct end address of memory ranges in device tree Geoff Levand
2016-07-27 22:45 ` Thiago Jung Bauermann
2016-07-27 23:23 ` Russell King - ARM Linux
2016-07-28 23:54 ` Thiago Jung Bauermann
2016-07-29 8:27 ` Russell King - ARM Linux
2016-07-29 17:12 ` Geoff Levand
2016-07-29 17:23 ` Russell King - ARM Linux
2016-08-01 4:52 ` AKASHI Takahiro
2016-09-06 0:29 ` Memory range end be inclusive or exclusive? " AKASHI Takahiro
2016-10-31 8:50 ` AKASHI Takahiro
2016-11-07 8:17 ` Simon Horman
2016-07-19 23:28 ` [PATCH v1 4/4] arm64: Add support for binary image files Geoff Levand
2016-07-19 23:28 ` [PATCH v1 3/4] arm64: Add arm64 kexec support Geoff Levand
2016-07-20 15:39 ` Mark Rutland
2016-07-20 19:19 ` Geoff Levand
2016-07-21 10:31 ` Mark Rutland
2016-07-21 10:50 ` Robin Murphy
2016-07-21 21:49 ` Geoff Levand
2016-07-22 4:08 ` Pratyush Anand
2016-07-22 5:33 ` AKASHI Takahiro
2016-07-22 9:54 ` Mark Rutland
2016-07-22 10:03 ` Robin Murphy
2016-07-22 13:56 ` Pratyush Anand
2016-07-22 17:59 ` Robin Murphy
2016-07-25 21:56 ` Geoff Levand
2016-07-20 17:53 ` Pratyush Anand
2016-07-20 20:33 ` Geoff Levand
2016-07-20 20:54 ` [PATCH v1.2 " Geoff Levand
2016-07-22 7:12 ` AKASHI Takahiro
2016-07-26 0:37 ` Geoff Levand
2016-07-25 14:28 ` Ruslan Bilovol
2016-07-25 20:50 ` Geoff Levand
2016-07-26 1:36 ` Ruslan Bilovol
2016-07-26 8:16 ` AKASHI Takahiro
2016-07-26 21:26 ` Ruslan Bilovol
2016-07-26 21:54 ` Geoff Levand
2016-07-19 23:28 ` [PATCH v1 2/4] kexec: Add common device tree routines Geoff Levand
2016-07-22 7:19 ` AKASHI Takahiro
2016-07-27 18:11 ` Geoff Levand [this message]
2016-07-20 4:30 ` [PATCH v1 0/4] arm64 kexec-tools patches AKASHI Takahiro
2016-07-26 23:05 ` Simon Horman
2016-07-27 5:57 ` AKASHI Takahiro
2016-07-28 18:09 ` Geoff Levand
2016-07-29 0:31 ` Simon Horman
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=1469643107.2889.65.camel@infradead.org \
--to=geoff@infradead.org \
--cc=linux-arm-kernel@lists.infradead.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).