From nobody Thu Dec 18 15:25:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8EE985947 for ; Wed, 10 Jul 2024 08:36:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720600599; cv=none; b=gWy6Ebvc3qs6kO1Woaba+9rMpegGoG3ouNky9/2Z3esu4VKNAn8t3WretfOp4LikvkZEYFfzzg1vHrIe+wlrh9tYs06gfjlzJ/yOUmGYAq4hc+UFtspFMjXcMoVeWvYZQA9At/g6RfjMI0tdoRjm7CqT6C53ew101NLVsRsTmk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720600599; c=relaxed/simple; bh=evQLV0pO07i+iE+j9o5IcO3BTGx5gXIQVZCSP53bD4c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a7bjA+merRyUdC6w2CfsdjrVrAfBVbWMAGA8V9NFq5YwDG/Bwc+smvRTLVIYzDB62rC+fd2xHMYfwG5AdjME5I8n2B9LybMOeAfuZidfH7yZxxD2ugC/9WmIsY54llRKrTWYqQ72cpWi0J8oSHkHN9UvBOSTaPLUYWor7w90Ch8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=i2s5EvpI; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i2s5EvpI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720600598; x=1752136598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=evQLV0pO07i+iE+j9o5IcO3BTGx5gXIQVZCSP53bD4c=; b=i2s5EvpIrGL8PWLMrKJ6Yokec1BEZ0w7tcIApQ8NiQ2oeqybRp+87Fvv pS4wEiV2kPVPYYdPVxYKSwhtTchm6+omXGeCGP7mxtEhivwnTy1Ohxgy5 TKFUzzV/uZDL0uwPwjjX9e2mu5/t8SaGZgZhbhOk1j3QcAGG2gdSDdPvL VbiDhCoQ/3viOjlfm123Fs9ew454Jg5sKatNHOOKecB2/R136vXqAICqO HCyRcvTPKpjNa/tjpXZhAf7O5Ut5KRWmuSLBaDFpkgTNeC9xmceftnPC8 XFBJOhoWWZ0/9rno3S2jdoVphGJ+RZ1Hdvt+JzmAendhv3On8LmHvb4m4 g==; X-CSE-ConnectionGUID: j72UTGOGQ1S1Y0cUAKeo4Q== X-CSE-MsgGUID: wJC+cFU+TMaOu1Z0oo82IQ== X-IronPort-AV: E=McAfee;i="6700,10204,11128"; a="17770965" X-IronPort-AV: E=Sophos;i="6.09,197,1716274800"; d="scan'208";a="17770965" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2024 01:36:37 -0700 X-CSE-ConnectionGUID: VbKz419FR6GpZFxj3Xqo7Q== X-CSE-MsgGUID: P3YDkvMtSiSWQygHyqEpHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,197,1716274800"; d="scan'208";a="48236135" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa010.fm.intel.com with ESMTP; 10 Jul 2024 01:36:35 -0700 From: Lu Baolu To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , Yi Liu Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/3] iommufd: Remove IOMMUFD_PAGE_RESP_FAILURE Date: Wed, 10 Jul 2024 16:33:39 +0800 Message-Id: <20240710083341.44617-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240710083341.44617-1-baolu.lu@linux.intel.com> References: <20240710083341.44617-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The response code of IOMMUFD_PAGE_RESP_FAILURE was defined to be equivalent to the "Response Failure" in PCI spec, section 10.4.2.1. This response code indicates that one or more pages within the associated request group have encountered or caused an unrecoverable error. Therefore, this response disables the PRI at the function. Modern I/O virtualization technologies, like SR-IOV, share PRI among the assignable device units. Therefore, a response failure on one unit might cause I/O failure on other units. Remove this response code so that user space can only respond with SUCCESS or INVALID. The VMM is recommended to emulate a failure response as a PRI reset, or PRI disable and changing to a non-PRI domain. Fixes: c714f15860fc ("iommufd: Add fault and response message definitions") Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian --- include/uapi/linux/iommufd.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index ede2b464a761..e31385b75d0b 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -765,14 +765,10 @@ struct iommu_hwpt_pgfault { * @IOMMUFD_PAGE_RESP_INVALID: Could not handle this fault, don't retry the * access. This is the "Invalid Request" in PCI * 10.4.2.1. - * @IOMMUFD_PAGE_RESP_FAILURE: General error. Drop all subsequent faults f= rom - * this device if possible. This is the "Respo= nse - * Failure" in PCI 10.4.2.1. */ enum iommufd_page_response_code { IOMMUFD_PAGE_RESP_SUCCESS =3D 0, IOMMUFD_PAGE_RESP_INVALID, - IOMMUFD_PAGE_RESP_FAILURE, }; =20 /** --=20 2.34.1 From nobody Thu Dec 18 15:25:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F39B013213D for ; Wed, 10 Jul 2024 08:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720600604; cv=none; b=rM/xVdNMDV9rUImrJBpOMnzoR+MB8vIop1zmAW+vIgRHq3Mvzz27b8OSJU/JCHTHDAUfgNhene5AQizaFXw1TrtXggTKumWgUlFXKaaJ5kD0do0vMWpfae2dmcOYIKzWF7+IRFugW6qKbbSAuFZecm77xzfpamC4q8mQsDcNA5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720600604; c=relaxed/simple; bh=QE6yDlRdiuYRWqF9/WCzWvWO0J0BeZi/moyxfPUj4eE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RfvJDQOdJyooVUBbo6RhacR7k4htTbC+JhyWHlnOPGioUPRJl6i1HjyZZYStTE7KqB24979o8WI186L9KVDNJ7vftzPj2WbYMI87RV1rmW+B4+bWT01rYqzD+D0wbGH9GfLAzFyIukTScoTlofFCArgeG2lsEJmv3ZsSzrkdqIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EUS0yKf4; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EUS0yKf4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720600603; x=1752136603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QE6yDlRdiuYRWqF9/WCzWvWO0J0BeZi/moyxfPUj4eE=; b=EUS0yKf4ADmIhJ3diYkq7jo+heWF7KmAQygGkaJuhj2ulIc/V9jA47gS YqW3Px7a7mUqmyBjMv2td6jAqb40nSIys2zzL8sVYwk2HSR2r0IKYpQNx 8P58UYfneh+4Fw2h+wxTIV6Jhjztr2UMJxBIuhY/pMZycdMuEHuUkzXvN Vp16StcYMHBAr+1bnwV3Af/J3jI4q2g0KIJJu2hqsk3uUuN8srj6Cti6a xQaYwfx9KxBxmNbRpaqXLyDXSVpypP110kOB2xwD/8W4cMi8M8PhdStqn J0NH1wBHkNK89kbA1wQNx7JC9SC1nhRkTNd9pvK4c7BQiPkxHvf3KNRGK A==; X-CSE-ConnectionGUID: AfJNwO1RRXqjzFtucDjqVw== X-CSE-MsgGUID: nPz7xGk6R1eEbaBhDJAAlg== X-IronPort-AV: E=McAfee;i="6700,10204,11128"; a="17770981" X-IronPort-AV: E=Sophos;i="6.09,197,1716274800"; d="scan'208";a="17770981" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2024 01:36:42 -0700 X-CSE-ConnectionGUID: 7Idk2f7NQdOGX7N/MG4Jdw== X-CSE-MsgGUID: ndSlM5TFQCWk1L1ooNVDrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,197,1716274800"; d="scan'208";a="48236160" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa010.fm.intel.com with ESMTP; 10 Jul 2024 01:36:37 -0700 From: Lu Baolu To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , Yi Liu Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 2/3] iommufd: Add check on user response code Date: Wed, 10 Jul 2024 16:33:40 +0800 Message-Id: <20240710083341.44617-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240710083341.44617-1-baolu.lu@linux.intel.com> References: <20240710083341.44617-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The response code from user space is only allowed to be SUCCESS or INVALID. All other values are treated by the device as a response code of Response Failure according to PCI spec, section 10.4.2.1. This response disables the Page Request Interface for the Function. Add a check in iommufd_fault_fops_write() to avoid invalid response code. Fixes: 07838f7fd529 ("iommufd: Add iommufd fault object") Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian --- drivers/iommu/iommufd/fault.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 54d6cd20a673..044b9b97da31 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -305,6 +305,12 @@ static ssize_t iommufd_fault_fops_write(struct file *f= ilep, const char __user *b if (rc) break; =20 + if (response.code !=3D IOMMUFD_PAGE_RESP_SUCCESS && + response.code !=3D IOMMUFD_PAGE_RESP_INVALID) { + rc =3D -EINVAL; + break; + } + group =3D xa_erase(&fault->response, response.cookie); if (!group) { rc =3D -EINVAL; --=20 2.34.1 From nobody Thu Dec 18 15:25:59 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C49913BACC for ; Wed, 10 Jul 2024 08:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720600605; cv=none; b=Pb8FSK8ieDw6ngm/O79zksN/hPZGZHabM55KGJfMVhLh7MQWhKJjTmiFF2cHCgTx5TBgix+frxQaHRkYutZ+p2k0ZtZyJRG2tlV9x+evO01zd2EYOEz4gRzm4sGAJbSUJDr44UEUKyEvPmGebcV4zA1H6YGSeLpHqXJJs0vrrv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720600605; c=relaxed/simple; bh=UhCCWJEn6oVsJ1nUvHZvdUm6DfrrEniO2iSlSPYCVNI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uf1ALXNHVeuTp4RBmFQS5DdvHBxW+wcRh/JxRhnJktLI/L0oNc5MdI5Wal2Px6ohZ3EI68yYcLS61ofNv6R2zGUcaVypsBZONRce/yWU2/WUaGYSQ1BSuHskNuaFfJshb1sLsYuoWnk93/9Z/AssFlQNoQXMpcbgB/TvnMUEt0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=V4Z8uNUs; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V4Z8uNUs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720600604; x=1752136604; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UhCCWJEn6oVsJ1nUvHZvdUm6DfrrEniO2iSlSPYCVNI=; b=V4Z8uNUs4nHj/GGZq5UoG4Ye/RO/iF3N2IcAf4VwWpv1Gf23loJ0UJDa k/j1NOjBaYiC2g2pObm3E7l72poYrJKLph235+aLWyrfgq0jV3gW3eVu3 gWwApdWh1f/MT7k+HN+wWb6SCKvzcCrOnzn8pzEZPWaOyRt7A1PB6jotG TuQD8+k/mvkio2HzY5cwnYkdA6B2NDFE5HI9WLsCnDa1HKfuTLM/xLStS 9ulCZmyyz2Qeog6TUgCUEHe42dF9k25BQfvUJrMkDDeoASA/8zXkrsVvF /GLOtR3MH7c1WqB2bwzxgnCaVh2wG8b+snIhJL0cUeaTGdpDV0rYuuc/F Q==; X-CSE-ConnectionGUID: wj0nuFI1QRGBq/HbpjXaZQ== X-CSE-MsgGUID: 8EISheBuR9Gd8M7N8ki+cQ== X-IronPort-AV: E=McAfee;i="6700,10204,11128"; a="17770984" X-IronPort-AV: E=Sophos;i="6.09,197,1716274800"; d="scan'208";a="17770984" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2024 01:36:43 -0700 X-CSE-ConnectionGUID: k01LmxDkRDiwdjUjuq2NIQ== X-CSE-MsgGUID: j777sBxlT1KXmEU35Rok6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,197,1716274800"; d="scan'208";a="48236177" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa010.fm.intel.com with ESMTP; 10 Jul 2024 01:36:40 -0700 From: Lu Baolu To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Nicolin Chen , Yi Liu Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 3/3] iommu: Convert response code from failure to invalid Date: Wed, 10 Jul 2024 16:33:41 +0800 Message-Id: <20240710083341.44617-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240710083341.44617-1-baolu.lu@linux.intel.com> References: <20240710083341.44617-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the iopf deliver path, iommu_report_device_fault() currently responds a code of "Response Failure" to the hardware if it can't find a suitable iopf-capable domain where the page faults should be handled. The Response Failure is defined in PCI spec (section 10.4.2.1) as a catastrophic error, and the device will disable PRI for the function. Failing to dispatch a set of fault messages is not a catastrophic error and the iommu core has no code to recover the PRI once it is disabled. Replace it with a response code of "Invalid Response". Fixes: b554e396e51c ("iommu: Make iopf_group_response() return void") Signed-off-by: Lu Baolu --- drivers/iommu/io-pgfault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/io-pgfault.c b/drivers/iommu/io-pgfault.c index cd679c13752e..b8270ee5dcdb 100644 --- a/drivers/iommu/io-pgfault.c +++ b/drivers/iommu/io-pgfault.c @@ -229,7 +229,7 @@ void iommu_report_device_fault(struct device *dev, stru= ct iopf_fault *evt) err_abort: dev_warn_ratelimited(dev, "iopf with pasid %d aborted\n", fault->prm.pasid); - iopf_group_response(group, IOMMU_PAGE_RESP_FAILURE); + iopf_group_response(group, IOMMU_PAGE_RESP_INVALID); if (group =3D=3D &abort_group) __iopf_free_group(group); else --=20 2.34.1