public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: Weinan Liu <wnliu@google.com>,
	iommu@lists.linux.dev, jgg@nvidia.com, joro@8bytes.org,
	suravee.suthikulpanit@amd.com
Cc: will@kernel.org, patches@lists.linux.dev, stable@vger.kernel.org,
	robin.murphy@arm.com, santosh.shukla@amd.com, chrisl@kernel.org
Subject: Re: [PATCH] iommu/amd: Fix precedence order in set_dte_passthrough()
Date: Mon, 4 May 2026 10:27:23 +0530	[thread overview]
Message-ID: <d355484d-d038-4393-ac06-a71ff1c69b50@amd.com> (raw)
In-Reply-To: <20260430232851.236666-1-wnliu@google.com>



On 5/1/2026 4:58 AM, Weinan Liu wrote:
> 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>

Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>

-Vasant

> ---
>  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,


      parent reply	other threads:[~2026-05-04  4:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d355484d-d038-4393-ac06-a71ff1c69b50@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=chrisl@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=patches@lists.linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=santosh.shukla@amd.com \
    --cc=stable@vger.kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    --cc=wnliu@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox