public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Fix precedence order in set_dte_passthrough()
@ 2026-04-30 23:28 Weinan Liu
  2026-05-01  0:00 ` Weinan Liu
  2026-05-04  4:57 ` Vasant Hegde
  0 siblings, 2 replies; 4+ messages in thread
From: Weinan Liu @ 2026-04-30 23:28 UTC (permalink / raw)
  To: iommu, jgg, joro, suravee.suthikulpanit
  Cc: will, patches, stable, robin.murphy, vasant.hegde, santosh.shukla,
	chrisl, Weinan Liu

Bitwise OR | operator has a higher precedence than the ternary ?:
operatior. It will be incorrectly evaluated as:

new->data[1] |= (FIELD_PREP(...) | dev_data->ats_enabled) ? DTE_FLAG_IOTLB : 0;

Wrap the conditional operation in parentheses to enforce the
correct evaluation order.

Fixes: 93eee2a49c1b ("iommu/amd: Refactor logic to program the host page table in DTE")
Signed-off-by: Weinan Liu <wnliu@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/amd/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 01171361f9bc..ccffbecb15c2 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2149,7 +2149,8 @@ static void set_dte_passthrough(struct iommu_dev_data *dev_data,
 	new->data[0] |= DTE_FLAG_TV | DTE_FLAG_IR | DTE_FLAG_IW;
 
 	new->data[1] |= FIELD_PREP(DTE_DOMID_MASK, domain->id) |
-			(dev_data->ats_enabled) ? DTE_FLAG_IOTLB : 0;
+			(dev_data->ats_enabled ? DTE_FLAG_IOTLB : 0);
+
 }
 
 static void set_dte_entry(struct amd_iommu *iommu,
-- 
2.54.0.545.g6539524ca2-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-04  4:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 23:28 [PATCH] iommu/amd: Fix precedence order in set_dte_passthrough() Weinan Liu
2026-05-01  0:00 ` Weinan Liu
2026-05-01  3:01   ` Chris Li
2026-05-04  4:57 ` Vasant Hegde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox