Linux IOMMU Development
 help / color / mirror / Atom feed
* [bug report] iommu/vt-d: Fix kdump kernels boot failure with scalable mode
@ 2022-09-15 10:05 Dan Carpenter
  2022-09-15 10:21 ` Robin Murphy
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2022-09-15 10:05 UTC (permalink / raw)
  To: baolu.lu; +Cc: Robin Murphy, iommu

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 but it will instead corrupt a bit way out
in the middle of your memory.  The set_bit function will only set one
bit at a time.  If we want to set bit zero:

	set_bit(0, iommu->copied_tables);

Or if we have a whole page full of bits then we could set the last one:

	set_bit(32767, page);

regards,
dan carpenter

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

end of thread, other threads:[~2022-09-15 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox