public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: iommu@lists.linux.dev, linux-kernel <linux-kernel@vger.kernel.org>
Subject: [bug report] iommu/amd: Introduce gDomID-to-hDomID Mapping and handle parent domain invalidation
Date: Fri, 6 Feb 2026 16:38:39 +0300	[thread overview]
Message-ID: <aYXu33WW8EqbXTlb@stanley.mountain> (raw)
In-Reply-To: <caa37f28-a2e8-4e0a-a9ce-a365ce805e4b@stanley.mountain>

[ Smatch checking is paused while we raise funding.  #SadFace
  https://lore.kernel.org/all/aTaiGSbWZ9DJaGo7@stanley.mountain/ -dan ]

Hello Suravee Suthikulpanit,

Commit 757d2b1fdf5b ("iommu/amd: Introduce gDomID-to-hDomID Mapping
and handle parent domain invalidation") from Jan 15, 2026
(linux-next), leads to the following Smatch static checker warning:

	drivers/iommu/amd/nested.c:161 amd_iommu_alloc_domain_nested()
	warn: 'gdom_info->hdom_id' unsigned <= 0

drivers/iommu/amd/nested.c
    148         /* Check if gDomID exist */
    149         if (refcount_inc_not_zero(&gdom_info->users)) {
    150                 ndom->gdom_info = gdom_info;
    151                 xa_unlock(&aviommu->gdomid_array);
    152 
    153                 pr_debug("%s: Found gdom_id=%#x, hdom_id=%#x\n",
    154                           __func__, ndom->gdom_id, gdom_info->hdom_id);
    155 
    156                 return &ndom->domain;
    157         }
    158 
    159         /* The gDomID does not exist. We allocate new hdom_id */
    160         gdom_info->hdom_id = amd_iommu_pdom_id_alloc();
--> 161         if (gdom_info->hdom_id <= 0) {

gdom_info->hdom_id is unsigned.  amd_iommu_pdom_id_alloc() can't return
zero.  It either returns negatives or 1-65535.

    162                 __xa_cmpxchg(&aviommu->gdomid_array,
    163                              ndom->gdom_id, gdom_info, NULL, GFP_ATOMIC);
    164                 xa_unlock(&aviommu->gdomid_array);
    165                 ret = -ENOSPC;
    166                 goto out_err_gdom_info;
    167         }
    168 
    169         ndom->gdom_info = gdom_info;

regards,
dan carpenter

           reply	other threads:[~2026-02-06 13:38 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <caa37f28-a2e8-4e0a-a9ce-a365ce805e4b@stanley.mountain>]

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=aYXu33WW8EqbXTlb@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suravee.suthikulpanit@amd.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