Commit 10161b4a authored by Weinan Liu's avatar Weinan Liu Committed by Joerg Roedel
Browse files

iommu/amd: Fix precedence order in set_dte_passthrough()



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: 93eee2a4 ("iommu/amd: Refactor logic to program the host page table in DTE")
Signed-off-by: default avatarWeinan Liu <wnliu@google.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarVasant Hegde <vasant.hegde@amd.com>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent f9471dc1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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,