[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 4/4] xen: rework paging_log_dirty_op to work with hvm guests



>>> On 07.05.15 at 16:29, <roger.pau@xxxxxxxxxx> wrote:
> --- a/xen/arch/x86/mm/paging.c
> +++ b/xen/arch/x86/mm/paging.c
> @@ -408,6 +408,51 @@ int paging_mfn_is_dirty(struct domain *d, mfn_t gmfn)
>      return rv;
>  }
>  
> +static inline void *map_dirty_bitmap(XEN_GUEST_HANDLE_64(uint8) dirty_bitmap,
> +                                     unsigned long pages,
> +                                     struct page_info **page)
> +{
> +    uint32_t pfec = PFEC_page_present | PFEC_write_access;
> +    unsigned long gfn;
> +    p2m_type_t p2mt;
> +
> +    gfn = paging_gva_to_gfn(current,
> +                            (paddr_t)(dirty_bitmap.p + (pages >> 3)),

Why paddr_t?

> @@ -455,6 +511,7 @@ static int paging_log_dirty_op(struct domain *d,
>                   d->arch.paging.log_dirty.fault_count,
>                   d->arch.paging.log_dirty.dirty_count);
>  
> +again:

Labels indented by at least one space please.

> @@ -472,18 +529,18 @@ static int paging_log_dirty_op(struct domain *d,
>      l4 = paging_map_log_dirty_bitmap(d);
>      i4 = d->arch.paging.preempt.log_dirty.i4;
>      i3 = d->arch.paging.preempt.log_dirty.i3;
> +    i2 = d->arch.paging.preempt.log_dirty.i2;

I don't see why this needs to be stored in struct domain - upon being
preempted you never seem to leave this non-zero.

> @@ -492,15 +549,34 @@ static int paging_log_dirty_op(struct domain *d,
>                      bytes = (unsigned int)((sc->pages - pages + 7) >> 3);
>                  if ( likely(peek) )
>                  {
> -                    if ( (l1 ? copy_to_guest_offset(sc->dirty_bitmap,
> -                                                    pages >> 3, (uint8_t 
> *)l1,
> -                                                    bytes)
> -                             : clear_guest_offset(sc->dirty_bitmap,
> -                                                  pages >> 3, bytes)) != 0 )
> +                    if ( pages >> (3 + PAGE_SHIFT) !=
> +                         index_mapped >> (3 + PAGE_SHIFT) )
>                      {
> -                        rv = -EFAULT;
> -                        goto out;
> +                        /* We need to map next page */
> +                        paging_unlock(d);
> +                        unmap_dirty_bitmap(dirty_bitmap, page);
> +                        index_mapped = pages;
> +                        dirty_bitmap = map_dirty_bitmap(sc->dirty_bitmap, 
> pages,
> +                                                        &page);
> +                        paging_lock(d);
> +                        if ( dirty_bitmap == NULL )
> +                        {
> +                            rv = -EFAULT;
> +                            goto out;
> +                        }
> +                        d->arch.paging.preempt.log_dirty.i4 = i4;
> +                        d->arch.paging.preempt.log_dirty.i3 = i3;
> +                        d->arch.paging.preempt.log_dirty.i2 = i2;
> +                        d->arch.paging.preempt.log_dirty.done = pages;
> +                        goto again;

I think you need to update the state before dropping the paging lock.
And that would then actually seem to make the new i2 field necessary.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.