lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOcK=COEd0njBPGhJ8idaLbaqvATr_zSB1O9dyzwi+fbU8GhqA@mail.gmail.com>
Date: Thu, 29 Aug 2024 10:33:50 +0200
From: Markus Rathgeb <maggu2810@...il.com>
To: "Tian, Kevin" <kevin.tian@...el.com>
Cc: Linux regressions mailing list <regressions@...ts.linux.dev>, Lu Baolu <baolu.lu@...ux.intel.com>, 
	Will Deacon <will@...nel.org>, David Woodhouse <dwmw2@...radead.org>, Joerg Roedel <joro@...tes.org>, 
	"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>, LKML <linux-kernel@...r.kernel.org>, 
	Jacob Pan <jacob.jun.pan@...ux.intel.com>, Adam Williamson <awilliam@...hat.com>
Subject: Re: [regression] usb and thunderbould are misbehaving or broken due
 to iommu/vt-d change

With respect to my previous comment I tested to fix it myself (I am
not a kernel hacker and do not know anything about iommu etc.).

After applying the following change to the v6.11-rc5 it seems to fix my problem.
I can connect, disconnect and connect the dock and USB is working and
no DMAR error.




>From 5f621c079f0f8bce9895ae05a9cd81b001a58089 Mon Sep 17 00:00:00 2001
From: Markus Rathgeb <maggu2810@...il.com>
Date: Thu, 29 Aug 2024 09:37:17 +0200
Subject: [PATCH] fix: iommu/vt-d: Add helper to flush caches for context
 change

Signed-off-by: Markus Rathgeb <maggu2810@...il.com>
---
 drivers/iommu/intel/iommu.c | 7 +++++--
 drivers/iommu/intel/iommu.h | 3 ++-
 drivers/iommu/intel/pasid.c | 4 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 9ff8b83c19a3..e92e06e604b2 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -1944,6 +1944,7 @@ static void domain_context_clear_one(struct
device_domain_info *info, u8 bus, u8
 {
     struct intel_iommu *iommu = info->iommu;
     struct context_entry *context;
+    u16 did_old;

     spin_lock(&iommu->lock);
     context = iommu_context_addr(iommu, bus, devfn, 0);
@@ -1952,10 +1953,12 @@ static void domain_context_clear_one(struct
device_domain_info *info, u8 bus, u8
         return;
     }

+    did_old = context_domain_id(context);
+
     context_clear_entry(context);
     __iommu_flush_cache(iommu, context, sizeof(*context));
     spin_unlock(&iommu->lock);
-    intel_context_flush_present(info, context, true);
+    intel_context_flush_present(info, context, did_old, true);
 }

 static int domain_setup_first_level(struct intel_iommu *iommu,
@@ -4269,7 +4272,7 @@ static int context_flip_pri(struct
device_domain_info *info, bool enable)

     if (!ecap_coherent(iommu->ecap))
         clflush_cache_range(context, sizeof(*context));
-    intel_context_flush_present(info, context, true);
+    intel_context_flush_present(info, context,
context_domain_id(context), true);
     spin_unlock(&iommu->lock);

     return 0;
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index b67c14da1240..0a4ce98faa60 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -988,7 +988,7 @@ static inline int context_domain_id(struct context_entry *c)
     return((c->hi >> 8) & 0xffff);
 }

-static inline void context_clear_entry(struct context_entry *context)
+static inline void     context_clear_entry(struct context_entry *context)
 {
     context->lo = 0;
     context->hi = 0;
@@ -1154,6 +1154,7 @@ void cache_tag_flush_range_np(struct dmar_domain
*domain, unsigned long start,

 void intel_context_flush_present(struct device_domain_info *info,
                  struct context_entry *context,
+                 u16 did,
                  bool affect_domains);

 #ifdef CONFIG_INTEL_IOMMU_SVM
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index 5792c817cefa..cb4bbb45ac2a 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -694,7 +694,7 @@ static void device_pasid_table_teardown(struct
device *dev, u8 bus, u8 devfn)
     context_clear_entry(context);
     __iommu_flush_cache(iommu, context, sizeof(*context));
     spin_unlock(&iommu->lock);
-    intel_context_flush_present(info, context, false);
+    intel_context_flush_present(info, context,
context_domain_id(context), false);
 }

 static int pci_pasid_table_teardown(struct pci_dev *pdev, u16 alias,
void *data)
@@ -885,10 +885,10 @@ static void __context_flush_dev_iotlb(struct
device_domain_info *info)
  */
 void intel_context_flush_present(struct device_domain_info *info,
                  struct context_entry *context,
+                 u16 did,
                  bool flush_domains)
 {
     struct intel_iommu *iommu = info->iommu;
-    u16 did = context_domain_id(context);
     struct pasid_entry *pte;
     int i;

-- 
2.46.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ