All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel@lists.xenproject.org, Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH RFC v2 2/3] xen/shadow: fix shadow_track_dirty_vram to work on hvm guests
Date: Thu, 9 Apr 2015 13:41:52 +0100	[thread overview]
Message-ID: <20150409124152.GL17031@deinos.phlegethon.org> (raw)
In-Reply-To: <551D933D.2030300@citrix.com>

At 20:06 +0100 on 02 Apr (1428005197), Andrew Cooper wrote:
> On 02/04/15 11:26, Roger Pau Monne wrote:
> > Modify shadow_track_dirty_vram to use a local buffer and then flush to the
> > guest without the paging_lock held. This is modeled after
> > hap_track_dirty_vram.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > Cc: Tim Deegan <tim@xen.org>
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>, subject to two
> corrections and a suggestion.
> 
> > ---
> >  xen/arch/x86/mm/shadow/common.c | 18 +++++++++++++++---
> >  1 file changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
> > index 2e43d6d..8fff43a 100644
> > --- a/xen/arch/x86/mm/shadow/common.c
> > +++ b/xen/arch/x86/mm/shadow/common.c
> > @@ -3516,7 +3516,7 @@ static void sh_clean_dirty_bitmap(struct domain *d)
> >  int shadow_track_dirty_vram(struct domain *d,
> >                              unsigned long begin_pfn,
> >                              unsigned long nr,
> > -                            XEN_GUEST_HANDLE_64(uint8) dirty_bitmap)
> > +                            XEN_GUEST_HANDLE_64(uint8) guest_dirty_bitmap)
> >  {
> >      int rc;
> >      unsigned long end_pfn = begin_pfn + nr;
> > @@ -3526,6 +3526,7 @@ int shadow_track_dirty_vram(struct domain *d,
> >      p2m_type_t t;
> >      struct sh_dirty_vram *dirty_vram;
> >      struct p2m_domain *p2m = p2m_get_hostp2m(d);
> > +    uint8_t *dirty_bitmap = NULL;
> >  
> >      if ( end_pfn < begin_pfn || end_pfn > p2m->max_mapped_pfn + 1 )
> >          return -EINVAL;
> > @@ -3554,6 +3555,12 @@ int shadow_track_dirty_vram(struct domain *d,
> >          goto out;
> >      }
> >  
> > +    dirty_bitmap = xzalloc_bytes(dirty_size);
> > +    if ( dirty_bitmap == NULL )
> > +    {
> > +        rc = -ENOMEM;
> > +        goto out;
> > +    }
> >      /* This should happen seldomly (Video mode change),
> >       * no need to be careful. */
> >      if ( !dirty_vram )
> > @@ -3587,7 +3594,7 @@ int shadow_track_dirty_vram(struct domain *d,
> >      {
> >          /* still completely clean, just copy our empty bitmap */
> >          rc = -EFAULT;
> > -        if ( copy_to_guest(dirty_bitmap, dirty_vram->dirty_bitmap, dirty_size) == 0 )
> > +        if ( memcpy(dirty_bitmap, dirty_vram->dirty_bitmap, dirty_size) != NULL )
> 
> memcpy() returns an int, not a pointer.

No, memcpy() returns a pointer, but it's always == its first argument
so there's no need to check it at all. :)

> > +    if ( rc == 0 && dirty_bitmap != NULL )
> > +        if ( copy_to_guest(guest_dirty_bitmap, dirty_bitmap, dirty_size) != 0 )
> > +            rc = -EFAULT;
> 
> These two if()s can be joined, and shorted for brevity.
> 
> if ( !rc && dirty_bitmap && copy_to_guest(guest_dirty_bitmap,
> dirty_bitmap, dirty_size) )
>     rc = -EFAULT;

+1.

Cheers,

Tim.

  reply	other threads:[~2015-04-09 12:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 10:26 [PATCH RFC v2 0/3] xen/pvh: enable migration on PVH Dom0 Roger Pau Monne
2015-04-02 10:26 ` [PATCH RFC v2 1/3] xen/pvh: enable mmu_update hypercall Roger Pau Monne
2015-04-02 10:42   ` Ian Campbell
2015-04-02 11:37     ` Roger Pau Monné
2015-04-02 11:50     ` Andrew Cooper
2015-04-02 12:43       ` Jürgen Groß
2015-04-02 12:56         ` Andrew Cooper
2015-04-02 10:26 ` [PATCH RFC v2 2/3] xen/shadow: fix shadow_track_dirty_vram to work on hvm guests Roger Pau Monne
2015-04-02 19:06   ` Andrew Cooper
2015-04-09 12:41     ` Tim Deegan [this message]
2015-04-09 12:45       ` Andrew Cooper
2015-04-02 10:26 ` [PATCH RFC v2 3/3] xen: rework paging_log_dirty_op to work with " Roger Pau Monne
2015-04-02 19:46   ` Andrew Cooper
2015-04-03 14:12     ` Tim Deegan
2015-04-07 10:09       ` Roger Pau Monné
2015-04-09 13:05         ` Tim Deegan
2015-04-09 13:01   ` Tim Deegan

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=20150409124152.GL17031@deinos.phlegethon.org \
    --to=tim@xen.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.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.