From: Tim Deegan Subject: Re: Xen-unstable-staging: Xen BUG at iommu_map.c:455 Date: Thu, 7 May 2015 11:32:06 +0100 Message-ID: <20150507103206.GB40944@deinos.phlegethon.org> References: <4810067032.20150411194249@eikelenboom.it> <55296730.30802@citrix.com> <1468678653.20150411213342@eikelenboom.it> <55298278.2080406@citrix.com> <1698372572.20150411230533@eikelenboom.it> <55299391.4030900@citrix.com> <20150416092830.GD13443@deinos.phlegethon.org> <5548F96E0200007800076C7F@mail.emea.novell.com> <20150505151711.GC31485@deinos.phlegethon.org> <5548FE7A0200007800076CD3@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YqJ6W-000402-9W for xen-devel@lists.xenproject.org; Thu, 07 May 2015 10:32:32 +0000 Content-Disposition: inline In-Reply-To: <5548FE7A0200007800076CD3@mail.emea.novell.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: Jan Beulich Cc: Andrew Cooper , Paul Durrant , Sander Eikelenboom , xen-devel List-Id: xen-devel@lists.xenproject.org At 16:31 +0100 on 05 May (1430843498), Jan Beulich wrote: > >>> On 05.05.15 at 17:17, wrote: > > At 16:10 +0100 on 05 May (1430842206), Jan Beulich wrote: > >> From what I > >> can tell (and assuming other code works correctly) the fact that > >> arch_iommu_populate_page_table() sets d->need_iommu to -1 > >> first thing should make sure that any subsequent changes to the > >> p2m get propagated to IOMMU code for setting up respective > >> mappings. > > > > Yes, but might they then be overridden by the previous mapping when > > this new code calls map_page()? > > Ah, I see now. > > > This seems like a case where we should be using get_gfn()/put_gfn(). > > Yes - provided these may be called at all with the page_alloc_lock > held. IOW - is there lock ordering defined between this one and > the various mm locks? Good point. The page_alloc lock nests inside the p2m lock, for PoD (see page_alloc_mm_pre_lock() in mm-locks.h). So we can't call p2m operations here. > Also, if doing so, would I then need to check the result of the > inverse (p2m) translation after having done get_gfn() to make > sure this is still the MFN I'm after? If so, and if it ends up being > a different one, I'd have to retry and presumably somehow limit > the number of retries... Yes. Ideally this loop would be iterating over all gfns in the p2m rather than over all owned MFNs. As long as needs_iommu gets set first, such a loop could safely be paused and restarted without worrying about concurrent updates. The code sould even stay in this file, though exposing an iterator from the p2m code would be a lot more efficient. In the meantime the patch you linked to is an improvement, so it can have my ack. Cheers, Tim.