All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev
Subject: Re: [bug report] iommu/vt-d: Fix kdump kernels boot failure with scalable mode
Date: Thu, 15 Sep 2022 13:44:01 +0300	[thread overview]
Message-ID: <YyMB8XxK3qHQtZ4V@kadam> (raw)
In-Reply-To: <b9e3f5cd-8888-cfc1-94a6-35ad54cd0122@arm.com>

On Thu, Sep 15, 2022 at 11:21:36AM +0100, Robin Murphy wrote:
> On 2022-09-15 11:05, Dan Carpenter wrote:
> > Hello Lu Baolu,
> > 
> > The patch 0c5f6c0d8201: "iommu/vt-d: Fix kdump kernels boot failure
> > with scalable mode" from Aug 23, 2022, leads to the following Smatch
> > static checker warning:
> > 
> > drivers/iommu/intel/iommu.c:224 set_context_copied() warn: set_bit() takes a bit number
> > drivers/iommu/intel/iommu.c:230 clear_context_copied() warn: clear_bit() takes a bit number
> > 
> > drivers/iommu/intel/iommu.c
> >      221 static inline void
> >      222 set_context_copied(struct intel_iommu *iommu, u8 bus, u8 devfn)
> >      223 {
> > --> 224         set_bit(((long)bus << 8) | devfn, iommu->copied_tables);
> >      225 }
> > 
> > This is trying to set a mask
> 
> No, it's simply composing a full 16-bit PCI requester ID from its two 8-bit
> components.
> 

Ah...  Okay.  That works then.

> > but it will instead corrupt a bit way out
> > in the middle of your memory.
> 
> 	iommu->copied_tables = bitmap_zalloc(BIT_ULL(16), GFP_KERNEL);
> 
> Again slightly non-obvious, but AFAICS the bitmap is sized appropriately.

Btw, just BIT(16) works until you get above 31.

regards,
dan carpenter


      reply	other threads:[~2022-09-15 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15 10:05 [bug report] iommu/vt-d: Fix kdump kernels boot failure with scalable mode Dan Carpenter
2022-09-15 10:21 ` Robin Murphy
2022-09-15 10:44   ` Dan Carpenter [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=YyMB8XxK3qHQtZ4V@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=robin.murphy@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.