From: "Jan Beulich" Subject: Re: [PATCH RFC 1/2] xen/pvh: take the p2m lock when doing logdirty ops from HVM domains Date: Thu, 16 Oct 2014 09:21:30 +0100 Message-ID: <543F9C2A020000780003F10A@mail.emea.novell.com> References: <1413370425-15015-1-git-send-email-roger.pau@citrix.com> <1413370425-15015-2-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XegJQ-00015j-FD for xen-devel@lists.xenproject.org; Thu, 16 Oct 2014 08:21:32 +0000 In-Reply-To: <1413370425-15015-2-git-send-email-roger.pau@citrix.com> Content-Disposition: inline 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, Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 15.10.14 at 12:53, wrote: > Due to locking order, the p2m lock must be taken before the paging lock, or > else the following panic occurs when trying to use logdirty ops from a PVH > Dom0: I agree with Andrew that you should audit all code paths for this problem, and either fix others as well or make clear in the description that no further similar issues were found. > --- a/xen/arch/x86/mm/paging.c > +++ b/xen/arch/x86/mm/paging.c > @@ -412,6 +412,8 @@ static int paging_log_dirty_op(struct domain *d, > > if ( !resuming ) > domain_pause(d); > + if (has_hvm_container_vcpu(current)) > + p2m_lock(p2m_get_hostp2m(current->domain)); Apart from the indentation issue already pointed out, the if() also violates our coding style (also again on all further instances). > paging_lock(d); I further wonder whether introducing a helper doing the paired locks/unlocks wouldn't be worthwhile. And of course I wonder about performance implications - the P2M lock is already a pretty contended one iirc. Jan