Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp426280lqb; Tue, 28 May 2024 22:40:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVFQ7+bWC67u+WexGIdx+ilftORw7VzyHW5gzGT8gk3Re6KI0T/PxVWYrPzqJO8UTLeZU1iT/DfjPj3WNMkrDDyA74Xupdz0e7AUGpDA== X-Google-Smtp-Source: AGHT+IE0VGOJBU4H6H809CoKXZQlmMm44UYJug80dsZau71hINHlTNXI2Gc8OL84t2d8Ep0+EsT+ X-Received: by 2002:ae9:e907:0:b0:792:c13a:1a80 with SMTP id af79cd13be357-794ab096177mr1400703885a.44.1716961258107; Tue, 28 May 2024 22:40:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716961258; cv=pass; d=google.com; s=arc-20160816; b=f5jRlriN2dwINt09YgqB06N/oqtRodHbNwdK90sszLwJJq7PXG4OZegqEHcUr7Nn9c Xlh1MXKSDlCcOhy2HiVVQlgBa4uS0Vko13zT4vv4Q0WA6OfpbCkq4YRG7NtOMjm3xeA5 pF+wEOeg8m7aSVt5VTJYEIxiyYf3Qg/QaGbKfm5vvra7BIXdW1se3rDFP8y3JzMfE2Cu qAUtywlyPNbkktgUaJw67kJSRrj88LZ57EDzMqhkNDu6czYtGg5720QGvrY0LLtOcOSj WVwhYRTzcMjTZrSwRxKIB3OuNdOy1NgN6V3v70OCeIwd9A6uHsfHyN4GlPS6R6ps+2Gw hgNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uAONlbMWVPU0pa2DvfIzSWtu0RhW7TayQdaJ0GxPZRE=; fh=u7VIfotmvhCnFPKh0R845OAh004BwcT1TGiZ1dQEGzo=; b=xLYQ3E6cs4v0VXBulbgf2w70b3hv2L2ns8lcZ7YqQbd3PnX2b2fsHY4W5tmdHsAE0u V/K3SzKVLT+Awe//6MJG5vu0eLmhuQ63flstnEtwbNNz2cY4PuYkAq1aoZsvEDsPEIAv L/7w7SZf6zxoSwIE9Zy6C/T9bO7o4irulMmOnVn98fKRKbj82eOlshJnLmcNJ+yUNnnL knNDkHHUtRFNHEpSq2o5qw3FFvMinAjKgxYR8CvJ3ilMB5OkAvCL+uIcnrJkYJwybJAH QH5t4MQ2F8LzxdqgVnX2cAy2bU8g/g4FNcpcQ7DJAs88le4R6HJhUXL6vPuFy+OPzign IupQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KD6w92b5; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193467-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193467-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794c89c4d20si552262585a.292.2024.05.28.22.40.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 22:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193467-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KD6w92b5; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193467-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193467-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 39E181C248DC for ; Wed, 29 May 2024 05:40:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF2FB16E86E; Wed, 29 May 2024 05:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KD6w92b5" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 95E0215CD7C for ; Wed, 29 May 2024 05:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960990; cv=none; b=uVchahVuJkPmf8j8eRzv2NayQjztIX3Sno406oQe7Qa5gp8I/PX4Z48av9hHwG+nnp2bWT5HqzcxJYM6br4Bp63nGInTUKxApYEUTANwABGLABP9k1/vwoESUa+zF0BMaxLXrMUj7vcLSAfI3incW5ppKO/MKYatjRYWewkwjbc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960990; c=relaxed/simple; bh=kMsYOm7U7Zn12dWdb7SeO0fPM3MLpopXhwDJqBymYTM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SJ04VewA86tAbL3UAvkLpmGly7s2urSG5fM7V2HVwD9Bi+kmaEz/0Q7N2AzSTQ85sUCIJ8vzRMsHLIeh4VlrcJv27R/AIVuDsxMO8kmNuvnQneYlG1DqDNUhe01c3kvmGpTfaqao37c4U0ZecaehNcOm0wFCIJNTc3a4aq+XqII= 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=KD6w92b5; arc=none smtp.client-ip=192.198.163.14 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960990; x=1748496990; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kMsYOm7U7Zn12dWdb7SeO0fPM3MLpopXhwDJqBymYTM=; b=KD6w92b591ULTsCPBxdeTYPBBGUbUiWfw567/e+elWWAzafFt/mpIrmP LC6pAyRe8A1b2/9iKwSk6jX26MLFzKqJeBs9c/IWQzI6mxd20NY80c0qm jrx8Wu2ccIOV5mXzF7B8gsmkxccs3ksg0QIW9eFuWr+5um27brlnfBYMU hOEVtPNkS/GdIDCOBPmw4im9JSU+ZkowDgr91s9piw7hUvkGBF0l+uudS 89jft2Rq4GT88uKPsBWH1YGgxOvr9+Zr5lC6JvOTz4AxX8R0u2xiBrbMs ZqU8f+5luoYv9i/RgLDO7jxlvTcV3fU3iKrFGBSdXQZdWtQElzZBF8cR4 A==; X-CSE-ConnectionGUID: +rSdfmSTS0KmxbZi4QBd1A== X-CSE-MsgGUID: M7Z02lI1TUO3T52ZFp8UGw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569082" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569082" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:23 -0700 X-CSE-ConnectionGUID: ImXU7FqzTUizFrnygOVsyA== X-CSE-MsgGUID: buiM+0knQZG9v/S3HkrdEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257777" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:18 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 17/20] iommu/vt-d: Simplify compatibility check for identity domain Date: Wed, 29 May 2024 13:32:47 +0800 Message-Id: <20240529053250.91284-18-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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: 8bit Currently, the identity domain attachment follows the same path as the paging domain attachment and is subject to the same compatibility checks as a normal paging domain. However, this level of check is unnecessary for the identity domain since it only requires the hardware to support passthrough mode, which is a given for modern hardware. On the early VT-d platforms, where hardware passthrough mode is not yet supported, the identity domain is supported by a makeshift paging domain with the entire system memory 1:1 mapped. For such early hardware, the appropriate domain type should be returned in device_def_domain_type(), and the identity domain should be simplified in compatibility checks. The identity domain workaround in prepare_domain_attach_device() is just temporary and should be removed once the identity domain is converted to have its own dedicated attachment path. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index eb8e08699b80..693a6d7c79ed 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2190,6 +2190,16 @@ static bool device_rmrr_is_relaxable(struct device *dev) */ static int device_def_domain_type(struct device *dev) { + struct device_domain_info *info = dev_iommu_priv_get(dev); + struct intel_iommu *iommu = info->iommu; + + /* + * Hardware does not support the passthrough translation mode. + * Always use a dynamaic mapping domain. + */ + if (!ecap_pass_through(iommu->ecap)) + return IOMMU_DOMAIN_DMA; + if (dev_is_pci(dev)) { struct pci_dev *pdev = to_pci_dev(dev); @@ -3802,6 +3812,14 @@ int prepare_domain_attach_device(struct iommu_domain *domain, struct intel_iommu *iommu = info->iommu; int addr_width; + /* + * This is a temporary solution as the identity domain attachment + * goes through this path as well. It should be removed once the + * identity domain has its own attach path. + */ + if (domain->type == IOMMU_DOMAIN_IDENTITY) + return ecap_pass_through(iommu->ecap) ? 0 : -EOPNOTSUPP; + if (dmar_domain->force_snooping && !ecap_sc_support(iommu->ecap)) return -EINVAL; -- 2.34.1