[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 3/3] AMD/IOMMU: iommu_enable vs iommu_intremap


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 21 Oct 2021 11:59:02 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S8lycJUP12YSt6T5Wbpdmvdqu/DvfiQPPEOn+K5M3nA=; b=ecIZgMieWg7NVgTYkd/T5d78nEJtd9L2Srti2Ft8KJ13l0jiSzjHsmETA5ufbyt02HhuiwMRzp4w76qnaW3Zp9yp3QM9rwYwTl5ZZnesPROJkj2Qb+04ddTHDrQqzTZMQR72mCxPSLy9CjOfUSAPw7M7enHXwEs4C4+awKPVJXinsLMqZVFffdFPA26OC4Z2heKVtwUVfllcBGVCsW9lgOtMGzFe6TjeHIvrYOeFk1i4hPAIx4SoqsfwuxpZSMF4QqE0G1eF5SkpKG26+Ch8KE9FWcsH45hlSoudNuPOQPQLKqZx6WRw/7Py4tsfy+EYnxhmDfVEZooq35tpeACzJA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZkknbpGdIEQPi/2D1frYSL30GnGufGxoJ1iLCZs/EyQlaQjZ+/6pMdlH5tBzPNDdlyj4YED4rrOmbfoO+1B5nQRKA9FTFuW19mQ4CtGxbY2g2cJrUq/hSnIm1wtigNzqZUQn2JSOIXo7qUiMK9V/tEPhTx9yaCHrStNdnAO5ptDzy5WhlXWjHmSgElLk3Jq0JwWnMDbE87fXRG406q5pFw17lkxe2q9Ztr1WVqCPTafrp2ihtotg+Q+OQxXuF1YIsSmhmwpAPBOdcpDQia0GBGJHRX0Aert5/cRirUpIf9i7SIZ2ibpwExCZLgW9BZ5ZbYgxSQHxzQYbxESRi/8ldw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 21 Oct 2021 09:59:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The two are really meant to be independent settings; iov_supports_xt()
using || instead of && was simply wrong. The corrected check is,
however, redundant, just like the (correct) one in iov_detect(): These
hook functions are unreachable without acpi_ivrs_init() installing the
iommu_init_ops pointer, which it does only upon success. (Unlike for
VT-d there is no late clearing of iommu_enable due to quirks, and any
possible clearing of iommu_intremap happens only after iov_supports_xt()
has run.)

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
In fact in iov_detect() it could be iommu_enable alone which gets
checked, but this felt overly aggressive to me. Instead I'm getting the
impression that the function may wrongly not get called when "iommu=off"
but interrupt remapping is in use: We'd not get the interrupt handler
installed, and hence interrupt remapping related events would never get
reported. (Same on VT-d, FTAOD.)

For iov_supports_xt() the question is whether, like VT-d's
intel_iommu_supports_eim(), it shouldn't rather check iommu_intremap
alone (in which case it would need to remain a check rather than getting
converted to ASSERT()).
---
v2: New.

--- a/xen/drivers/passthrough/amd/iommu_intr.c
+++ b/xen/drivers/passthrough/amd/iommu_intr.c
@@ -731,8 +731,7 @@ bool __init iov_supports_xt(void)
 {
     unsigned int apic;
 
-    if ( !iommu_enable || !iommu_intremap )
-        return false;
+    ASSERT(iommu_enable || iommu_intremap);
 
     if ( amd_iommu_prepare(true) )
         return false;
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -199,8 +199,7 @@ int __init acpi_ivrs_init(void)
 
 static int __init iov_detect(void)
 {
-    if ( !iommu_enable && !iommu_intremap )
-        return 0;
+    ASSERT(iommu_enable || iommu_intremap);
 
     if ( (init_done ? amd_iommu_init_late()
                     : amd_iommu_init(false)) != 0 )




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.