From: Julien Grall <julien.grall@linaro.org>
To: Frediano Ziglio <frediano.ziglio@huawei.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Tim Deegan <tim@xen.org>
Cc: Zoltan Kiss <zoltan.kiss@huawei.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Date: Wed, 05 Nov 2014 15:28:48 +0000 [thread overview]
Message-ID: <545A4230.9030506@linaro.org> (raw)
In-Reply-To: <B944B469BF5302468AC6EB05E56CC70D17B396@lhreml509-mbb>
On 11/05/2014 03:13 PM, Frediano Ziglio wrote:
> How does sound something like this (already tested, it's working).
The idea looks good to me. Few comments below.
Also, I'm wondering if we could create a generic function for this
purpose. The code of the GICv3 suffers of the same problem.
> Perhaps just to be paranoid a test on len after reading reg property
would be perfect.
The property/node has been validated in the GICv2 initialization.
Checking again here is not necessary.
>
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 2f6bbd5..2c4d097 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -632,7 +632,7 @@ static int gicv2_make_dt_node(const struct domain *d,
> const void *compatible = NULL;
> u32 len;
> __be32 *new_cells, *tmp;
> - int res = 0;
> + int res = 0, na, ns;
>
> compatible = dt_get_property(gic, "compatible", &len);
> if ( !compatible )
> @@ -664,15 +664,27 @@ static int gicv2_make_dt_node(const struct domain *d,
> if ( res )
> return res;
>
> - len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node));
> + /* copy GICC and GICD regions */
> + na = dt_n_addr_cells(node);
> + ns = dt_n_size_cells(node);
> +
> + if ( na != dt_n_addr_cells(gic) || ns != dt_n_size_cells(gic) )
> + return -FDT_ERR_XEN(EINVAL);
Not necessary, the caller of this function already check that gic (i.e
dt_interrupt_controller) == node.
If you really to be safe, I would add ASSERT(gic == node);
> +
> + tmp = (__be32 *) dt_get_property(gic, "reg", &len);
The cast is not necessary.
> + if ( !tmp )
> + {
> + dprintk(XENLOG_ERR, "Can't find reg property for the gic node\n");
> + return -FDT_ERR_XEN(ENOENT);
> + }
> +
> + len = dt_cells_to_size(na + ns);
> len *= 2; /* GIC has two memory regions: Distributor + CPU interface */
> new_cells = xzalloc_bytes(len);
> if ( new_cells == NULL )
> return -FDT_ERR_XEN(ENOMEM);
>
> - tmp = new_cells;
> - dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
> - dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
> + memcpy(new_cells, tmp, len);
You don't need to copy the data in the temporary variable. You can
directly use fdt_property with the right len. Smth like:
fdt_property(fdt, "reg", tmp, len);
Regards,
--
Julien Grall
next prev parent reply other threads:[~2014-11-05 15:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 9:41 [PATCH v3] xen/arm: Add support for Huawei hip04-d01 platform Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 1/8] xen/device_tree: Add new helper to read arrays from a DTB Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 2/8] xen/arm: Implement hip04-d01 platform Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 3/8] xen/arm: Make gic-v2 code handle " Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2 Frediano Ziglio
2014-11-05 13:48 ` Julien Grall
2014-11-05 14:52 ` Stefano Stabellini
2014-11-06 9:46 ` Zoltan Kiss
2014-11-06 9:54 ` Julien Grall
2014-11-06 10:13 ` Frediano Ziglio
2014-11-07 13:36 ` Julien Grall
2014-11-07 14:34 ` Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 5/8] xen/arm: handle GICH register changes for hip04-d01 platform Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 6/8] xen/arm: Force dom0 to use normal GICv2 driver on Hip04 platform Frediano Ziglio
2014-11-05 9:41 ` [PATCH v3 7/8] xen/device_tree: Add dt_device_get_address_raw Frediano Ziglio
2014-11-05 14:18 ` Julien Grall
2014-11-05 9:41 ` [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains Frediano Ziglio
2014-11-05 14:18 ` Julien Grall
2014-11-05 14:54 ` Zoltan Kiss
2014-11-05 14:58 ` Julien Grall
2014-11-05 15:13 ` Frediano Ziglio
2014-11-05 15:28 ` Julien Grall [this message]
2014-11-05 15:46 ` Frediano Ziglio
2014-11-05 15:51 ` Julien Grall
2014-11-05 15:52 ` Julien Grall
2014-11-05 16:02 ` Frediano Ziglio
2014-11-05 13:38 ` [PATCH v3] xen/arm: Add support for Huawei hip04-d01 platform Julien Grall
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=545A4230.9030506@linaro.org \
--to=julien.grall@linaro.org \
--cc=frediano.ziglio@huawei.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=zoltan.kiss@huawei.com \
/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.