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: <171450758612.10851.13609092281484392070.stgit@linux.ibm.com>
Date: Tue, 30 Apr 2024 15:06:29 -0500
From: Shivaprasad G Bhat <sbhat@...ux.ibm.com>
To: mpe@...erman.id.au, tpearson@...torengineering.com,
        alex.williamson@...hat.com, linuxppc-dev@...ts.ozlabs.org, aik@....com
Cc: npiggin@...il.com, christophe.leroy@...roup.eu, aneesh.kumar@...nel.org,
        naveen.n.rao@...ux.ibm.com, gbatra@...ux.vnet.ibm.com,
        brking@...ux.vnet.ibm.com, sbhat@...ux.ibm.com, aik@...abs.ru,
        jgg@...pe.ca, ruscur@...sell.cc, robh@...nel.org,
        linux-kernel@...r.kernel.org, joel@....id.au, kvm@...r.kernel.org,
        msuchanek@...e.de, oohall@...il.com, mahesh@...ux.ibm.com,
        jroedel@...e.de, vaibhav@...ux.ibm.com, svaidy@...ux.ibm.com
Subject: [RFC PATCH v2 4/6] vfio/spapr: Always clear TCEs before unsetting the
 window

The PAPR expects the TCE table to have no entries at the time of
unset window(i.e. remove-pe). The TCE clear right now is done
before freeing the iommu table. On pSeries, the unset window
makes those entries inaccessible to the OS and the H_PUT/GET calls
fail on them with H_CONSTRAINED.

On PowerNV, this has no side effect as the TCE clear can be done
before the DMA window removal as well.

Signed-off-by: Shivaprasad G Bhat <sbhat@...ux.ibm.com>
---
 drivers/vfio/vfio_iommu_spapr_tce.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index a94ec6225d31..5f9e7e477078 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -364,7 +364,6 @@ static void tce_iommu_release(void *iommu_data)
 		if (!tbl)
 			continue;
 
-		tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size);
 		tce_iommu_free_table(container, tbl);
 	}
 
@@ -720,6 +719,8 @@ static long tce_iommu_remove_window(struct tce_container *container,
 
 	BUG_ON(!tbl->it_size);
 
+	tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size);
+
 	/* Detach groups from IOMMUs */
 	list_for_each_entry(tcegrp, &container->group_list, next) {
 		table_group = iommu_group_get_iommudata(tcegrp->grp);
@@ -738,7 +739,6 @@ static long tce_iommu_remove_window(struct tce_container *container,
 	}
 
 	/* Free table */
-	tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size);
 	tce_iommu_free_table(container, tbl);
 	container->tables[num] = NULL;
 
@@ -1197,9 +1197,14 @@ static void tce_iommu_release_ownership(struct tce_container *container,
 		return;
 	}
 
-	for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i)
-		if (container->tables[i])
+	for (i = 0; i < IOMMU_TABLE_GROUP_MAX_TABLES; ++i) {
+		if (container->tables[i]) {
+			tce_iommu_clear(container, container->tables[i],
+					container->tables[i]->it_offset,
+					container->tables[i]->it_size);
 			table_group->ops->unset_window(table_group, i);
+		}
+	}
 }
 
 static long tce_iommu_take_ownership(struct tce_container *container,



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ