From: Tim Deegan <tim@xen.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Julien Grall <julien.grall@linaro.org>,
jaeyong.yoo@samsung.com,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v4 1/9] xen/arm: Implement hvm save and restore
Date: Tue, 8 Oct 2013 10:06:17 +0100 [thread overview]
Message-ID: <20131008090617.GA40780@ocelot.phlegethon.org> (raw)
In-Reply-To: <1381222420.9920.9.camel@kazak.uk.xensource.com>
At 09:53 +0100 on 08 Oct (1381226020), Ian Campbell wrote:
> On Tue, 2013-10-08 at 06:30 +0000, Jaeyong Yoo wrote:
>
> > >> +static void vgic_irq_rank_save(struct vgic_rank *ext,
> > >> + struct vgic_irq_rank *rank)
> > >> +{
> > >> + spin_lock(&rank->lock);
> > >> + /* Some of VGIC registers are not used yet, it is for a future usage */
> > >> + /* IENABLE, IACTIVE, IPEND, PENDSGI registers */
> > >> + ext->ienable = rank->ienable;
> > >> + ext->iactive = rank->iactive;
> > >> + ext->ipend = rank->ipend;
> > >> + ext->pendsgi = rank->pendsgi;
> > >> + /* ICFG */
> > >> + ext->icfg[0] = rank->icfg[0];
> > >> + ext->icfg[1] = rank->icfg[1];
> > >Can you use memcpy?
>
> Why?
>
> > OK.
>
> If ext->icfg[0] rank->icfg[0] are the same type then I think using
> assignment is better, since it is more type safe and it will effectively
> get turned into a memcpy by the compiler anyway.
+1. memcpy is dangerous here.
On x86 we avoided (much of) this kind of thing by just using the
API-defined structs directly in the internal ones. Then there's no need
for any copying at all in this kind of function, just save the struct
out.
Of course, you have to be careful to separate architectural state (which
goes in the save record) from Xen implementation detail (which must not).
Tim.
> If they are different types then using memcpy just runs the risk that
> one of them will silently change and break things.
>
> With that in mind can these not be proper assignments too:
>
> > >> + /* IPRIORITY */
> > >> + memcpy(ext->ipriority, rank->ipriority, sizeof(rank->ipriority));
> > >> + /* ITARGETS */
> > >> + memcpy(ext->itargets, rank->itargets, sizeof(rank->itargets));
>
> Or if not then copy field by field would actually be preferable IMHO. A
> helper macro can make it a bit tidier sometimes:
> #define C(F) ext->#F = rank->#F
>
> then
> C(itargets.foo);
> C(itergets.bar);
> #undef C
> etc.
>
> Ian.
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-10-08 9:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 6:30 [PATCH v4 1/9] xen/arm: Implement hvm save and restore Jaeyong Yoo
2013-10-08 8:53 ` Ian Campbell
2013-10-08 9:06 ` Tim Deegan [this message]
2013-10-09 12:34 ` Jaeyong Yoo
-- strict thread matches above, loose matches on Subject: below --
2013-10-04 4:43 [PATCH v4 0/9] xen/arm: live migration support in arndale board Jaeyong Yoo
2013-10-04 4:43 ` [PATCH v4 1/9] xen/arm: Implement hvm save and restore Jaeyong Yoo
2013-10-07 12:49 ` 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=20131008090617.GA40780@ocelot.phlegethon.org \
--to=tim@xen.org \
--cc=Ian.Campbell@citrix.com \
--cc=jaeyong.yoo@samsung.com \
--cc=julien.grall@linaro.org \
--cc=xen-devel@lists.xen.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).