From: "Jan Beulich" Subject: Re: [PATCH v3] IOMMU: Prevent VT-d device IOTLB operations on wrong IOMMU Date: Wed, 18 Jun 2014 11:18:04 +0100 Message-ID: <53A1756C02000078000B697C@mail.emea.novell.com> References: <0ec71ff08df1f10b1d41.1403015866@malcolmc.uk.xensource.com> <53A07589020000780001B253@mail.emea.novell.com> <53A06993.9010608@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53A06993.9010608@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: malcolm.crossley@citrix.com Cc: kevin.tian@intel.com, andrew.cooper3@citrix.com, xen-devel@lists.xen.org, paul.durrant@citrix.com, Aravind.Gopalakrishnan@amd.com, suravee.suthikulpanit@amd.com, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org >>> Malcolm Crossley 06/17/14 6:15 PM >>> >On 17/06/14 16:06, Jan Beulich wrote: >>>>> On 17.06.14 at 16:37, wrote: >>> --- a/xen/drivers/passthrough/vtd/x86/ats.c >>> +++ b/xen/drivers/passthrough/vtd/x86/ats.c >>> @@ -120,6 +120,10 @@ int dev_invalidate_iotlb(struct iommu *i >>> { >>> sid = (pdev->bus << 8) | pdev->devfn; >>> >>> + /* Only invalidate devices that belong to this IOMMU */ >>> + if ( !pdev->iommu || pdev->iommu != iommu ) >>> + continue; >> >> I meant to ask before and then forgot: What is the first half of this >> condition good/needed for? >> >Defensive coding to prevent a NULL pointer deference if the Intel or >core ATS code goes wrong. But there is no de-reference of the pointer anywhere - you added it just as a token for comparison purposes. If pdev->iommu was NULL, the right side comparison should still produce "false"... Jan