All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Mukesh Rathor <mukesh.rathor@oracle.com>
Cc: xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 02/20] PVH xen: add XENMEM_add_to_physmap_range
Date: Fri, 17 May 2013 07:37:16 +0100	[thread overview]
Message-ID: <5195EC3C02000078000D6E7D@nat28.tlf.novell.com> (raw)
In-Reply-To: <20130516165639.4697b751@mantra.us.oracle.com>

>>> On 17.05.13 at 01:56, Mukesh Rathor <mukesh.rathor@oracle.com> wrote:
> On Thu, 16 May 2013 08:21:16 +0100
> "Jan Beulich" <JBeulich@suse.com> wrote:
> 
>> >>> On 16.05.13 at 01:05, Mukesh Rathor <mukesh.rathor@oracle.com>
>> >>> wrote:
>> > On Wed, 15 May 2013 10:58:43 +0100
>> > "Jan Beulich" <JBeulich@suse.com> wrote:
>> > 
>> >> >>> On 15.05.13 at 02:52, Mukesh Rathor <mukesh.rathor@oracle.com>
>> >> >>> wrote:
>> >> > --- a/xen/arch/x86/mm.c
>> >> > +++ b/xen/arch/x86/mm.c
>> >> > @@ -4519,7 +4519,8 @@ static int handle_iomem_range(unsigned long
>> >> > s, unsigned long e, void *p) 
>> >> >  static int xenmem_add_to_physmap_once(
>> >> >      struct domain *d,
>> >> > -    const struct xen_add_to_physmap *xatp)
>> >> > +    const struct xen_add_to_physmap *xatp,
>> >> > +    domid_t foreign_domid)
>> >> >  {
>> >> >      struct page_info *page = NULL;
>> >> >      unsigned long gfn = 0; /* gcc ... */
>> >> > @@ -4646,7 +4647,7 @@ static int xenmem_add_to_physmap(struct
>> >> > domain *d,
>> >> 
>> >> I know I said this before: This patch can't be complete, or else
>> >> the new function parameter would actually get used. With the way
>> >> things are, if this patch gets applied, a user of the new XENMEM_
>> >> sub-op would not get the expected behavior.
>> >> 
>> > 
>> > No, the new foreign_domid parameter is meaningful for only the 
>> > XENMAPSPACE_gmfn_foreign OP which is defined in patch 0018. So we 
>> > should be OK here.
>> 
>> Mukesh, please. Go look at your own patch again: It adds handling
>> of XENMEM_add_to_physmap_range to arch_memory_op(), calling
>> xenmem_add_to_physmap_range(), which in turn calls
>> xenmem_add_to_physmap_once() passing xatpr->foreign_domid
>> as the last argument. I don't see anywhere in the patch prevention
>> of that execution flow for an arbitrary guest. If I'm overlooking
>> something, please point me to it.
> 
> Hmm..., looking at the code again, xenmem_add_to_physmap_once() will
> start with setting mfn=0, then in the case statement, it won't find 
> XENMAPSPACE_gmfn_foreign, so will get out of switch to :
> 
>     if ( !paging_mode_translate(d) || (mfn == 0) )
> 
> Since mfn is 0, it will return -EINVAL. The error would be copied
> to the xatpr->errs and guest will see that.  What am I missing?

Okay, I see now, but that was entirely unrecognizable from
patch context and patch description.

> I can
> add full support in just one patch, adding patch 18 here, but then in
> the past I was asked to break big patches. 

With the above briefly stated in the patch description, I'm fine
with you keeping it separate.

>> Furthermore, now that you forced me to look at that code yet
>> another time,
>> 
>> >+        xen_ulong_t idx;
>> >+        xen_pfn_t gpfn;
>> 
>> Pointless variables, ...
>> 
>> >+        struct xen_add_to_physmap xatp;
>> >+
>> >+        if ( copy_from_guest_offset(&idx, xatpr->idxs,
>> >xatpr->size-1, 1)  ||
>> >+             copy_from_guest_offset(&gpfn, xatpr->gpfns,
>> >xatpr->size-1, 1) )
>> 
>> ... you can read directly into the respective xatp fields here.
> 
> I could, but it makes the lines long/wrap in the if statement making the 
> code
> harder to read IMO. The compiler should do exact same thing in both cases.

I'm afraid it's not permitted to do so because of the addresses of
the variables being taken and, through some macro levels, passed
to global functions.

> If it really bothers you, I can change it.

It's certainly a matter of taste to some degree, but to me it's
inefficient code (unless you could prove at least modern gcc indeed
doing said optimization despite the use of the & operator) and
would sooner or later (once stumbling across that code again)
prompt me to submit a cleanup patch...

Jan

  reply	other threads:[~2013-05-17  6:37 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15  0:52 [PATCH 00/20][V5]: PVH xen: version 5 patches Mukesh Rathor
2013-05-15  0:52 ` [PATCH 01/20] PVH xen: turn gdb_frames/gdt_ents into union Mukesh Rathor
2013-05-15  0:52 ` [PATCH 02/20] PVH xen: add XENMEM_add_to_physmap_range Mukesh Rathor
2013-05-15  9:58   ` Jan Beulich
2013-05-15 23:05     ` Mukesh Rathor
2013-05-16  7:21       ` Jan Beulich
2013-05-16 11:03         ` Stefano Stabellini
2013-05-16 12:01           ` Jan Beulich
2013-05-16 15:04             ` Stefano Stabellini
2013-05-16 23:56         ` Mukesh Rathor
2013-05-17  6:37           ` Jan Beulich [this message]
2013-05-17 22:24             ` Mukesh Rathor
2013-05-15  0:52 ` [PATCH 03/20] PVH xen: create domctl_memory_mapping() function Mukesh Rathor
2013-05-15 10:07   ` Jan Beulich
2013-05-15  0:52 ` [PATCH 04/20] PVH xen: add params to read_segment_register Mukesh Rathor
2013-05-15  0:52 ` [PATCH 05/20] PVH xen: vmx realted preparatory changes for PVH Mukesh Rathor
2013-05-15  0:52 ` [PATCH 06/20] PVH xen: Move e820 fields out of pv_domain struct Mukesh Rathor
2013-05-15 10:27   ` Jan Beulich
2013-05-15  0:52 ` [PATCH 07/20] PVH xen: Introduce PVH guest type Mukesh Rathor
2013-05-15  0:52 ` [PATCH 08/20] PVH xen: tools changes to create PVH domain Mukesh Rathor
2013-05-15  0:52 ` [PATCH 09/20] PVH xen: domain creation code changes Mukesh Rathor
2013-05-15  0:52 ` [PATCH 10/20] PVH xen: create PVH vmcs, and also initialization Mukesh Rathor
2013-05-15  0:52 ` [PATCH 11/20] PVH xen: introduce pvh.c Mukesh Rathor
2013-05-15 10:42   ` Jan Beulich
2013-05-16  1:42     ` Mukesh Rathor
2013-05-16  8:00       ` Jan Beulich
2013-05-17  0:27         ` Mukesh Rathor
2013-05-17  6:43           ` Jan Beulich
2013-05-21  0:08             ` Mukesh Rathor
2013-05-21  7:07               ` Jan Beulich
2013-05-15  0:52 ` [PATCH 12/20] PVH xen: create read_descriptor_sel() Mukesh Rathor
2013-05-15  0:52 ` [PATCH 13/20] PVH xen: introduce vmx_pvh.c Mukesh Rathor
2013-05-15 11:46   ` Jan Beulich
2013-05-15  0:52 ` [PATCH 14/20] PVH xen: some misc changes like mtrr, intr, msi Mukesh Rathor
2013-05-15  0:52 ` [PATCH 15/20] PVH xen: hcall page initialize, create PVH guest type, etc Mukesh Rathor
2013-05-15  0:52 ` [PATCH 16/20] PVH xen: Miscellaneous changes Mukesh Rathor
2013-05-15 11:53   ` Jan Beulich
2013-05-16  1:51     ` Mukesh Rathor
2013-05-15  0:52 ` [PATCH 17/20] PVH xen: Introduce p2m_map_foreign Mukesh Rathor
2013-05-15 11:55   ` Jan Beulich
2013-05-15  0:52 ` [PATCH 18/20] PVH xen: Add and remove foreign pages Mukesh Rathor
2013-05-15 12:05   ` Jan Beulich
2013-05-15  0:52 ` [PATCH 19/20] PVH xen: elf and iommu related changes to prep for dom0 PVH Mukesh Rathor
2013-05-15 12:12   ` Jan Beulich
2013-05-16  1:58     ` Mukesh Rathor
2013-05-16  8:03       ` Jan Beulich
2013-05-17  1:14         ` Mukesh Rathor
2013-05-17  6:45           ` Jan Beulich
2013-05-18  2:01         ` Mukesh Rathor
2013-05-21  7:14           ` Jan Beulich
2013-05-15  0:52 ` [PATCH 20/20] PVH xen: PVH dom0 creation Mukesh Rathor

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=5195EC3C02000078000D6E7D@nat28.tlf.novell.com \
    --to=jbeulich@suse.com \
    --cc=mukesh.rathor@oracle.com \
    --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 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.