From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753677AbcGLLsO (ORCPT ); Tue, 12 Jul 2016 07:48:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:35653 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753478AbcGLLsM (ORCPT ); Tue, 12 Jul 2016 07:48:12 -0400 Date: Tue, 12 Jul 2016 13:48:06 +0200 From: Joerg Roedel To: Robin Murphy Cc: Joerg Roedel , iommu@lists.linux-foundation.org, Vincent.Wan@amd.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/20] iommu/amd: Remove special mapping code for dma_ops path Message-ID: <20160712114806.GC27306@suse.de> References: <1467978311-28322-1-git-send-email-joro@8bytes.org> <1467978311-28322-8-git-send-email-joro@8bytes.org> <5784CCAB.8000007@arm.com> <20160712110839.GF12639@8bytes.org> <5784D7C3.4010104@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5784D7C3.4010104@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On Tue, Jul 12, 2016 at 12:42:59PM +0100, Robin Murphy wrote: > Ah, that's the angle I was missing, yes. So if, say, someone is mapping > a page at IOVA 0x0000 while someone else is mapping a page at 0x1000, > there could still be a race between both callers writing the non-leaf > PTEs, but it's benign since they'd be writing identical entries anyway. > Seems reasonable to me (I assume in a similar map vs. unmap race, the > unmapper would just be removing the leaf entry, rather than bothering to > check for empty tables and tear down intermediate levels, so the same > still applies). The non-leaf PTE setup code checks for races with cmpxchg, so we are on the safe side there. Two threads would write different entries there, because they are allocating differnt sub-pages, but as I said, this is checked for using cmpxchg. On the PTE level this problem does not exist. Joerg