Received: by 10.223.164.202 with SMTP id h10csp535834wrb; Mon, 6 Nov 2017 10:47:56 -0800 (PST) X-Google-Smtp-Source: ABhQp+QphxEGe5kyhRo4pegYnH73fx8/Ta8hqJSfOSLqKDimGX2A7WXQGpozQ6QVpYvFXgsszjn6 X-Received: by 10.84.131.34 with SMTP id 31mr15678227pld.449.1509994076336; Mon, 06 Nov 2017 10:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509994076; cv=none; d=google.com; s=arc-20160816; b=U3qIjpeBRPC012fiQnu1tkjZx5HVAd3GnJEuMcK31I+VlAcPITqQqznjgbN79AO53q UbjhO244DLIi12yY/+1KHaU8WXNoObn5ovOSS8Xt8i2EUciPKUaJTbqyI6QTQgKI4vdd ShwbcZtWWhnuuEYc8zhWhXirlsVFYB0ywKbxrY8xlBgAc7Zw0GFIVIWL77y2jbgwiZod dnCS8Tmx5FgWyMsE7k/j5rpjQt4kmnQoLHdHxpwHf/eM3A3M2w6JQs+tY6cySlRR+l0o RGIh5JcsN1OftpAJ8hmtQFwVV+k9ISUy8mUjOKLHHAcrMGVTHoP+MV2Hc0fBJO1pRU1U IpfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=uqWyfQb9PQOmPOe75Ytbe+Ke+wKuJ9SLt8zVIa120AE=; b=AIU9mCEmQOwJPMBkZ5DE6o9B4sbFwMQHFp3vLo30Ilf8/8iF+WcRwRTaq7LQTzYMhK tR2ja/JK92dR9n+J8ahl/Vi2DQHQaX+kOZI4pE7XVPj/8FPWMj+p7kdz2aTomf+flF20 TPYHt64dYWTT6qt7oBFdnH525hAEbzupM2vOUeJuJNDcfg8fTmql82izJ3jTaqmPdchp 2hlueXkpAnCpDlK0eENSG9dvmLnLv+MPO3DIY55rgqNfF4SoyFsKFzeqZdvTBGCob7KO Tn0uN4OFNPMHEwTSh5YUyR4TukHiAhGmjyM+OtvANi+RfCSnpSm9bHo2NluQFbuqkZsc 0J6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x67si12573258pfi.166.2017.11.06.10.47.42; Mon, 06 Nov 2017 10:47:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754660AbdKFSqR (ORCPT + 95 others); Mon, 6 Nov 2017 13:46:17 -0500 Received: from mga03.intel.com ([134.134.136.65]:55815 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753867AbdKFSqQ (ORCPT ); Mon, 6 Nov 2017 13:46:16 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2017 10:46:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,353,1505804400"; d="scan'208";a="146583106" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga004.jf.intel.com with ESMTP; 06 Nov 2017 10:46:15 -0800 Date: Mon, 6 Nov 2017 10:47:09 -0800 From: Jacob Pan To: Joerg Roedel Cc: Robin Murphy , leedom@chelsio.com, herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-crypto@vger.kernel.org, David Woodhouse , Harsh@chelsio.com, jacob.jun.pan@linux.intel.com, Alex Williamson Subject: Re: [PATCH] iommu/vt-d: Fix scatterlist offset handling Message-ID: <20171106104709.06b38f7c@jacob-builder> In-Reply-To: <20171006144309.GA30803@8bytes.org> References: <644c3e01654f8bd48d669c36e424959d6ef0e27e.1506607370.git.robin.murphy@arm.com> <1507035334.29211.105.camel@infradead.org> <20171006144309.GA30803@8bytes.org> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Oct 2017 16:43:09 +0200 Joerg Roedel wrote: > On Tue, Oct 03, 2017 at 07:05:17PM +0100, Robin Murphy wrote: > > Now, there are indeed plenty of drivers and subsystems which do > > work on lists of explicitly single pages - anything doing some > > variant of "addr = kmap_atomic(sg_page(sg)) + sg->offset;" is easy > > to spot - but I don't think DMA API implementations are in a > > position to make any kind of assumption; nearly all of them just > > shut up and handle sg->length bytes from sg_phys(sg) without > > questioning the caller, and I reckon that's exactly what they > > should be doing. > > I agree with that, it is not explicitly forbidden to have an > sg->offset > PAGE_SIZE and most IOMMU drivers handle this case. > > So this is a problem I'd like to see resolved in the VT-d driver too. > If nobody comes up with a correct fix soon I'll apply this one and > rip out the large-page support from __domain_mapping() to make it > work. > Hi All, Just to give an update on the offline debugging of this issue. With Robin's patch applied, I was able to reproduce the failure with similar configuration that Jain helped to set up. I added trace prints just to see the map/unmap activities leading to the DMAR fault. When fault occurs, the trace shows there is an unmap to the offending iova pfn. So I think this is a separate problem than Robin's patch is fixing. I think we should move forward to merge this patch upstream and stable. The remaining problem is likely a race condition between unmap and DMA activities. Here a brief extracted log, ee3d7 is the iova pfn in question. #1. map sg pfn ee3d7 -0 [076] 74124.154254: bprint: __domain_mapping: vpfn:ee3d7, pgoff=2126, np:1, da:ee3d784e, len:1464 , ppfn:1849c9c #2. unmap ee3d7000 -0 [054] 74124.154301: bprint: intel_unmap: Device 0000:18:00.4 unmapping: pfn ee3d7-ee3d7 -0 [076] 74124.154301: bprint: __domain_mapping: lvlpg:1, nrpg 0, vpfn:ec2ff, ppfn:183221a, sg_res:0 -0 [059] 74124.154302: bprint: __domain_mapping: lvlpg:1, nrpg 0, vpfn:ee719, ppfn:c3e4dd, sg_res:0 -0 [076] 74124.154302: bprint: __domain_mapping: vpfn:f183b, pgoff=78, np:1, da:f183b04e, len:1464, #3. DMA to unmapped address ee3d7000, DMAR fault raised. +2.952861] dmar_fault: 6 callbacks suppressed +0.000002] DMAR: DRHD: handling fault status reg 2 +0.005588] turning tracing off +0.003592] DMAR: [DMA Write] Request device [18:00.4] fault addr ee3d7000 [fault reason 05] PTE Write access is not set -0 [000] 74124.156906: bputs: 0xffffffffb259916bs: turning tracing off Thanks, Jacob > Speaking of __domain_mapping(), this function is a big unmaintainable > mess which should be split and rewritten. A clean and maintainable > rewrite can alse re-add the large-page support. > > > Regards, > > Joerg > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu [Jacob Pan] From 1580525593411860368@xxx Fri Oct 06 16:17:44 +0000 2017 X-GM-THRID: 1579793157804914964 X-Gmail-Labels: Inbox,Category Forums