Linux IOMMU Development
 help / color / mirror / Atom feed
* [bug report] iommufd: Add a selftest
@ 2022-11-15 12:49 Dan Carpenter
  2022-11-15 13:25 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-11-15 12:49 UTC (permalink / raw)
  To: jgg; +Cc: iommu

Hello Jason Gunthorpe,

The patch 147393321d65: "iommufd: Add a selftest" from Nov 19, 2021,
leads to the following Smatch static checker warning:

	drivers/iommu/iommufd/selftest.c:160 mock_domain_map_pages()
	warn: use 'gfp' here instead of GFP_XXX?

drivers/iommu/iommufd/selftest.c
   133  static int mock_domain_map_pages(struct iommu_domain *domain,
   134                                   unsigned long iova, phys_addr_t paddr,
   135                                   size_t pgsize, size_t pgcount, int prot,
   136                                   gfp_t gfp, size_t *mapped)
   137  {
   138          struct mock_iommu_domain *mock =
   139                  container_of(domain, struct mock_iommu_domain, domain);
   140          unsigned long flags = MOCK_PFN_START_IOVA;
   141          unsigned long start_iova = iova;
   142  
   143          /*
   144           * xarray does not reliably work with fault injection because it does a
   145           * retry allocation, so put our own failure point.
   146           */
   147          if (iommufd_should_fail())
   148                  return -ENOENT;
   149  
   150          WARN_ON(iova % MOCK_IO_PAGE_SIZE);
   151          WARN_ON(pgsize % MOCK_IO_PAGE_SIZE);
   152          for (; pgcount; pgcount--) {
   153                  size_t cur;
   154  
   155                  for (cur = 0; cur != pgsize; cur += MOCK_IO_PAGE_SIZE) {
   156                          void *old;
   157  
   158                          if (pgcount == 1 && cur + MOCK_IO_PAGE_SIZE == pgsize)
   159                                  flags = MOCK_PFN_LAST_IOVA;
   160                          old = xa_store(&mock->pfns, iova / MOCK_IO_PAGE_SIZE,
   161                                         xa_mk_value((paddr / MOCK_IO_PAGE_SIZE) |
   162                                                     flags),
   163                                         GFP_KERNEL);
                                               ^^^^^^^^^^
"gfp" isn't used anywhere so maybe it was intended here?



   164                          if (xa_is_err(old)) {
   165                                  for (; start_iova != iova;
   166                                       start_iova += MOCK_IO_PAGE_SIZE)
   167                                          xa_erase(&mock->pfns,
   168                                                   start_iova /
   169                                                           MOCK_IO_PAGE_SIZE);
   170                                  return xa_err(old);
   171                          }
   172                          WARN_ON(old);
   173                          iova += MOCK_IO_PAGE_SIZE;
   174                          paddr += MOCK_IO_PAGE_SIZE;

regards,
dan carpenter

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

end of thread, other threads:[~2022-11-15 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 12:49 [bug report] iommufd: Add a selftest Dan Carpenter
2022-11-15 13:25 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox