Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1759563rbb; Mon, 26 Feb 2024 23:20:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/bTvqTr1sNCe1GuCUhoQSxqU8w0YlPkWR4kjmltTYa6yMvUsQI2ryOdF+D988y1pDgp20yiT7W7TeEKDSxecd7qCa4G7mkHAGqhsFYQ== X-Google-Smtp-Source: AGHT+IGviel1FDVmxu8ZYlXHy8bIxRBZCvrB0CWIDwzAdkimeAGOyEWeULdqcfPkXmCVuMiH6Rj+ X-Received: by 2002:a17:906:6701:b0:a3f:6717:37ae with SMTP id a1-20020a170906670100b00a3f671737aemr6359006ejp.69.1709018457945; Mon, 26 Feb 2024 23:20:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709018457; cv=pass; d=google.com; s=arc-20160816; b=vvUjS/64gD3N4k/w3bZcmkLHo5vxKd/yCF/IhjiQMXhmmDs3EqkK9je2JLEvYejYM1 b0r+Jdh80z0KPTZCDPJlBeedqMTCVf9povg22u1ZTVbjpZwt7Rc5AaQR90BM9VFjuln2 COEtKhz85R4TvS/SglgPBwXO86FAFrD72ZdBe2oR1+OXV1i9kQKYB2ceuJ9JXIfVZN2c 8tW18vrBBIAoii18EXxuTJl30krCi2rsNazsuyX1PydOPlWsOnjmQMjjSrO5ZgvWcm3i YMvPD1xPPZVG+DHvNe6g/A4keFdF3zCWnMZiPgyM3zSQejRwy75pPAvkG1ioALDGwEfU qvig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FQ3ECuKh6c0xuGXZyTU0bxO9IeMYLwcYWqGnI4Uk05A=; fh=ZR8tiH0KEZS3RDxWcHkCRD99qAe9lOLEfYjx/vr90sk=; b=rdwKv8orm4vXhzhkl1575A6oHnToPl01uTkBPyQ7L25JyWUajET5P8FS+/kXZKFTJC AvqaxMBbWE42CiEx42T25ZNGJbeKudi1NW7wgJnh7evyKLfIwLFwX4qa5sJQ7WJLLzeO jo1jJghU9b/kN6GqyfmBGskg9iL2R3JLQoJQI2V+p3y9wuRVmAnlUVW6al9tn+Uj00+m mUp0IYcJZ5cGFRdmo1WgOAd1rzMvb5k9B2I5AQvKwXJ8z98qPc+HyjILy0KHvWK7z8eB JeruRAkAaiWmN0vvP3GZV3uMwYSDxSSl1p9TDVrkWFvRlweZV0bfC7DCc7r2aQ3Voxus aZrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XAvCS9LG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-82792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d18-20020a170906371200b00a3e7a8db720si479411ejc.279.2024.02.26.23.20.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:20:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XAvCS9LG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-82792-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8B88D1F22D9E for ; Tue, 27 Feb 2024 07:20:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EEC654BC8; Tue, 27 Feb 2024 07:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XAvCS9LG" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 170145467A for ; Tue, 27 Feb 2024 07:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709018448; cv=none; b=J/SYXdiiJB04KYw13n+vPmLQ/dt4wSHBtb0oA+yY5GDTT/X3lRSjk3bkKnBH4oOqwxuHMFC23izLcq7TLyp4vxceBfy3saZn4RB4uJLdFuXdrdQ2wkzbqjYVU3gs/DzyqT/jWWqbiUcluREDszFVqFkcsh33SsqexDHfKlenKOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709018448; c=relaxed/simple; bh=jFD+J/7osmXKpIC3TFgHsoSYx1D/6a4Vkb0pR6Tszwg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sBB+HbDdxJAPP4+APk4DnaCGpPD24kcPH35yzyVNIwpSkFfQjOO1no7Yf0xgwjeTvwI3bRB1WswFl8uC7z3XAuY0HkIRaOhrUQMb9c3GJsU6cLx8AH2weavt1v9La6L5QqtJYhJ4KHrpAHJhX8SxoI+yQ3GyQRo5LmFxswsTPIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=XAvCS9LG; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-412aec2505dso737225e9.2 for ; Mon, 26 Feb 2024 23:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709018445; x=1709623245; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=FQ3ECuKh6c0xuGXZyTU0bxO9IeMYLwcYWqGnI4Uk05A=; b=XAvCS9LGhcW2MaquASW1wbA753N/w/TTJ3AYPFhinuL0pywxdvngxbRnRdxGwsAF4u XT3qzTR/gIEJqkbdeKbxxBtGzLvf2CNJKAlhq8PUHqZ/LF19gToKx9VXnxWLBSvitnGr 15j+Wb16WDvUbpOHqAfIV+tvvRXCmG2j3y/iqwGb9XAM2M3J0ss7vq2+QGMDggsaF3vC puVdCDWcaVyNGC2TAuazFnuuqX+WWQp15M6XiaDsUJL3xqbADxzZxNX84A37JDVZsNnF Z7GEs/jgA4QG0mFm82kgbdo/1i3GeOESiboF280PJEFW1UVyymYn/QxVsqZQUXxab77R I3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709018445; x=1709623245; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FQ3ECuKh6c0xuGXZyTU0bxO9IeMYLwcYWqGnI4Uk05A=; b=j6FWSzSXogayvfgpAXl9X2dSLal3RGqnG+gCdLOJEgdRSiU5wJ3ZPKsgrRuLw5aVL5 j6JWoXX5UBUcPYpKLCzobeTxg2J9OMNsFLwqrnW1BVlH57IuK59Ws7LnCQ8Qt4yFJ3dm LhyUanmiXzu4Dp8c+0CxZk0xvT4J4ZKfWOPlqugUaTDDHigdX79F+Kxt/LD/D+WkM5uh df6bNOapUdTfknBO4BxP3Hdds0vRbaBcvIliUOT0+LAiQ0sb0EJM+PoXCaBXObk5PfDO AACEd5X8vOfJR1+gshsQ9V5cmOOmOqlwOHVDoBMdJGbsdYNZ9iT26ePexeQWNjozaqZ0 BBjA== X-Forwarded-Encrypted: i=1; AJvYcCVV/IWHaF1dkCxt/HGYWfSErVnFS+NYGYspQSWU+EjAsPpmhncMsZ9HEAuh6rsD5yJfnkqEGLqzHU5XnJOW1pgzXGcFiCI71wyyBTRp X-Gm-Message-State: AOJu0YxT3gRuaoMmqF5LeVMxIfj8qYjZqLw1d/2rxmfU+DDuWvn40y4m Qk6zxbA+/I9zG0gKtB3MWUVsb7RV34Kj8TnFkjs/hf7fMrLIKSVN/LkBt3QzU/4= X-Received: by 2002:a05:600c:3154:b0:410:8071:6931 with SMTP id h20-20020a05600c315400b0041080716931mr6781548wmo.20.1709018445251; Mon, 26 Feb 2024 23:20:45 -0800 (PST) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id g10-20020adfd1ea000000b0033d282c7537sm10772977wrd.23.2024.02.26.23.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:20:44 -0800 (PST) Date: Tue, 27 Feb 2024 07:54:06 +0300 From: Dan Carpenter To: Ethan Zhao Cc: baolu.lu@linux.intel.com, bhelgaas@google.com, robin.murphy@arm.com, jgg@ziepe.ca, kevin.tian@intel.com, dwmw2@infradead.org, will@kernel.org, lukas@wunner.de, yi.l.liu@intel.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v13 3/3] iommu/vt-d: improve ITE fault handling if target device isn't valid Message-ID: <8a220db4-a784-4dbf-9c6d-dcb4b47c0083@moroto.mountain> References: <20240222090251.2849702-1-haifeng.zhao@linux.intel.com> <20240222090251.2849702-4-haifeng.zhao@linux.intel.com> <2d1788da-521c-4531-a159-81d2fb801d6c@linux.intel.com> <039a19e5-d1ff-47ae-aa35-3347c08acc13@moroto.mountain> <31ee6660-ad4a-40b8-8503-ebc3ed06dd16@linux.intel.com> <623ce65f-da43-4493-8a21-4fd6dfe86dbb@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <623ce65f-da43-4493-8a21-4fd6dfe86dbb@linux.intel.com> On Tue, Feb 27, 2024 at 04:00:33AM +0800, Ethan Zhao wrote: > > + if (!dev || !dev_is_pci(dev)) > > + return -ETIMEDOUT; > > + pdev = to_pci_dev(dev); > > + if (!pci_device_is_present(pdev) && > > + ite_sid == pci_dev_id(pci_physfn(pdev))) > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Unless the device_rbtree_find() is returning garbage then these things > > must be true. > > > > + return -ETIMEDOUT; > > > > I tried to double check how we were storing devices into the rbtree, > > but then I discovered that the device_rbtree_find() doesn't exist in > > linux-next and this patch breaks the build. > > > > This is very frustrating thing. But let's say a buggy BIOS could mess > > up the rbtree. In that situation, we would still want to change the && > > to an ||. If the divice is not present and^W or the rbtree is corrupted > > Maybe you meant > + if (!pci_device_is_present(pdev) || > + ite_sid != pci_dev_id(pci_physfn(pdev))) Yep, that's what I was asking. > > Unfortunately, the ite_sid we got from the "Invalidation Queue Error Record Register" is the *PCI Requester-id* of faulty device, that could be different > BDF as the sid in the ATS invalidation request for devices: > > 1. behind the PCIe to PCI bridges. > 2. behindConventional PCI Bridges 3.PCI Express* Devices Using Phantom > Functions 4.Intel? Scalable I/O Virtualization Capable Devices (e.g. ADI) > 5. devices with ARI function. > 6. behind root port without ACS enabled. > ... ... Fair enough... Thanks. regards, dan carpenter