From: Tim Deegan Subject: Re: [PATCH v6 4/4] xen: rework paging_log_dirty_op to work with hvm guests Date: Thu, 14 May 2015 10:53:17 +0100 Message-ID: <20150514095317.GD81528@deinos.phlegethon.org> References: <1431354328-30453-1-git-send-email-roger.pau@citrix.com> <1431354328-30453-5-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsppP-0003wb-K7 for xen-devel@lists.xenproject.org; Thu, 14 May 2015 09:53:19 +0000 Content-Disposition: inline In-Reply-To: <1431354328-30453-5-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: xen-devel@lists.xenproject.org, Jan Beulich , Andrew Cooper List-Id: xen-devel@lists.xenproject.org At 16:25 +0200 on 11 May (1431361528), Roger Pau Monne wrote: > When the caller of paging_log_dirty_op is a hvm guest Xen would choke when > trying to copy the dirty bitmap to the guest because the paging lock is > already held. > = > Fix this by independently mapping each page of the guest bitmap as needed > without the paging lock held. > = > Signed-off-by: Roger Pau Monn=E9 This looks mostly correct, but OTOH we now seem to have two nested stop-and-retry mechsnisms in one function. I think this would be cleaner if here: > + if ( pages >> (3 + PAGE_SHIFT) !=3D > + index_mapped >> (3 + PAGE_SHIFT) ) > { > - rv =3D -EFAULT; > - goto out; > + /* We need to map next page */ > + d->arch.paging.preempt.log_dirty.i4 =3D i4; > + d->arch.paging.preempt.log_dirty.i3 =3D i3; > + d->arch.paging.preempt.log_dirty.i2 =3D i2; > + d->arch.paging.preempt.log_dirty.done =3D pages; > + paging_unlock(d); > + unmap_dirty_bitmap(dirty_bitmap, page); we set the rest of the preempt state, like so: d->arch.paging.preempt.dom =3D current->domain; d->arch.paging.preempt.op =3D sc->op; resuming =3D 1; and bailed to the very top of the function. I think we might also need a hypercall_preempt_check() here as well, so that this restart path doesn't stop us ever reaching the preempt_checks below. Cheers, Tim.