From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [yiliu1765-iommufd:wip/iommufd_nesting_08042023-yi 12/57] drivers/iommu/iommufd/device.c:358 iommufd_must_remove_rr() error: we previously assumed 'new_hwpt' could be null (see line 341)
Date: Sun, 6 Aug 2023 21:52:22 +0800 [thread overview]
Message-ID: <202308062128.ASglP8pP-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Yi Liu <yi.l.liu@intel.com>
TO: Kevin Tian <kevin.tian@intel.com>
tree: https://github.com/yiliu1765/iommufd.git wip/iommufd_nesting_08042023-yi
head: 298b42007955fc150cad88c629de50dab7050f15
commit: cec938742db5c16708db0642a49e51085bee34f6 [12/57] iommufd: Handle IOMMU_RESV_SW_MSI complication with user-managed HWPTs
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: i386-randconfig-m021-20230806 (https://download.01.org/0day-ci/archive/20230806/202308062128.ASglP8pP-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230806/202308062128.ASglP8pP-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202308062128.ASglP8pP-lkp@intel.com/
New smatch warnings:
drivers/iommu/iommufd/device.c:358 iommufd_must_remove_rr() error: we previously assumed 'new_hwpt' could be null (see line 341)
drivers/iommu/iommufd/device.c:433 iommufd_must_enforce_rr() error: we previously assumed 'old_hwpt' could be null (see line 414)
Old smatch warnings:
drivers/iommu/iommufd/device.c:1265 iommufd_access_rw() error: uninitialized symbol 'rc'.
vim +/new_hwpt +358 drivers/iommu/iommufd/device.c
e8d57210035b637 Jason Gunthorpe 2022-11-29 329
588f26078f3dfd4 Nicolin Chen 2023-08-01 330 static bool iommufd_must_remove_rr(struct iommufd_hw_pagetable *old_hwpt,
cec938742db5c16 Nicolin Chen 2023-08-02 331 struct iommufd_hw_pagetable *new_hwpt,
cec938742db5c16 Nicolin Chen 2023-08-02 332 bool *keep_sw_msi)
588f26078f3dfd4 Nicolin Chen 2023-08-01 333 {
cec938742db5c16 Nicolin Chen 2023-08-02 334 struct iommufd_ioas *old_ioas, *new_ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 335
cec938742db5c16 Nicolin Chen 2023-08-02 336 if (old_hwpt->user_managed)
cec938742db5c16 Nicolin Chen 2023-08-02 337 old_ioas = old_hwpt->parent->ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 338 else
cec938742db5c16 Nicolin Chen 2023-08-02 339 old_ioas = old_hwpt->ioas;
588f26078f3dfd4 Nicolin Chen 2023-08-01 340
588f26078f3dfd4 Nicolin Chen 2023-08-01 @341 if (!new_hwpt)
588f26078f3dfd4 Nicolin Chen 2023-08-01 342 new_ioas = NULL;
cec938742db5c16 Nicolin Chen 2023-08-02 343 else if (new_hwpt->user_managed)
cec938742db5c16 Nicolin Chen 2023-08-02 344 new_ioas = new_hwpt->parent->ioas;
588f26078f3dfd4 Nicolin Chen 2023-08-01 345 else
588f26078f3dfd4 Nicolin Chen 2023-08-01 346 new_ioas = new_hwpt->ioas;
588f26078f3dfd4 Nicolin Chen 2023-08-01 347
588f26078f3dfd4 Nicolin Chen 2023-08-01 348 /* When switching IOAS, cleaning up the old IOAS is a must */
cec938742db5c16 Nicolin Chen 2023-08-02 349 if (old_ioas != new_ioas) {
cec938742db5c16 Nicolin Chen 2023-08-02 350 *keep_sw_msi = false;
cec938742db5c16 Nicolin Chen 2023-08-02 351 return true;
cec938742db5c16 Nicolin Chen 2023-08-02 352 }
cec938742db5c16 Nicolin Chen 2023-08-02 353
cec938742db5c16 Nicolin Chen 2023-08-02 354 /*
cec938742db5c16 Nicolin Chen 2023-08-02 355 * Must keep IOMMU_RESV_SW_MSI when switching from a kernel-managed
cec938742db5c16 Nicolin Chen 2023-08-02 356 * hw_pagetable to its associated user-managed hw_pagetable.
cec938742db5c16 Nicolin Chen 2023-08-02 357 */
cec938742db5c16 Nicolin Chen 2023-08-02 @358 if (!old_hwpt->user_managed && new_hwpt->user_managed) {
cec938742db5c16 Nicolin Chen 2023-08-02 359 *keep_sw_msi = true;
588f26078f3dfd4 Nicolin Chen 2023-08-01 360 return true;
cec938742db5c16 Nicolin Chen 2023-08-02 361 }
cec938742db5c16 Nicolin Chen 2023-08-02 362 /*
cec938742db5c16 Nicolin Chen 2023-08-02 363 * Do not remove in the remaining cases when IOAS isn't changed:
cec938742db5c16 Nicolin Chen 2023-08-02 364 * - switching from a kernel-managed hw_pagetable to another kernel-
cec938742db5c16 Nicolin Chen 2023-08-02 365 * managed hw_pagetable associated to the same IOAS. All the existing
cec938742db5c16 Nicolin Chen 2023-08-02 366 * reserved regions remain in the IOAS in this case.
cec938742db5c16 Nicolin Chen 2023-08-02 367 * - switching from a user-managed hw_pagetable to an associated kernel-
cec938742db5c16 Nicolin Chen 2023-08-02 368 * managed hw_pagetable. In this case, all reserved regions must have
cec938742db5c16 Nicolin Chen 2023-08-02 369 * been enforced in the IOAS, i.e. no removal after the enforcement.
cec938742db5c16 Nicolin Chen 2023-08-02 370 * - switching from a user-managed hw_pagetable to another user-managed
cec938742db5c16 Nicolin Chen 2023-08-02 371 * hw_pagetable associated to the same parent hw_pagetable (or IOAS).
cec938742db5c16 Nicolin Chen 2023-08-02 372 * In this case, the existing IOMMU_RESV_SW_MSI regions must be kept.
cec938742db5c16 Nicolin Chen 2023-08-02 373 */
588f26078f3dfd4 Nicolin Chen 2023-08-01 374 return false;
588f26078f3dfd4 Nicolin Chen 2023-08-01 375 }
588f26078f3dfd4 Nicolin Chen 2023-08-01 376
588f26078f3dfd4 Nicolin Chen 2023-08-01 377 /*
588f26078f3dfd4 Nicolin Chen 2023-08-01 378 * Remove device's reserved regions from the reserved list of an iopt
588f26078f3dfd4 Nicolin Chen 2023-08-01 379 * @idev: Device to remove its owned reserved regions
588f26078f3dfd4 Nicolin Chen 2023-08-01 380 * @hwpt: Detaching hw_pagetable
588f26078f3dfd4 Nicolin Chen 2023-08-01 381 * @new_hwpt: Optionally new hw_pagetable to replace with
588f26078f3dfd4 Nicolin Chen 2023-08-01 382 *
588f26078f3dfd4 Nicolin Chen 2023-08-01 383 * Call this function when an idev detaches or replaces an attached hwpt
588f26078f3dfd4 Nicolin Chen 2023-08-01 384 */
588f26078f3dfd4 Nicolin Chen 2023-08-01 385 static void iommufd_device_remove_rr(struct iommufd_device *idev,
588f26078f3dfd4 Nicolin Chen 2023-08-01 386 struct iommufd_hw_pagetable *hwpt,
588f26078f3dfd4 Nicolin Chen 2023-08-01 387 struct iommufd_hw_pagetable *new_hwpt)
588f26078f3dfd4 Nicolin Chen 2023-08-01 388 {
cec938742db5c16 Nicolin Chen 2023-08-02 389 struct iommufd_ioas *ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 390 bool keep_sw_msi;
cec938742db5c16 Nicolin Chen 2023-08-02 391
588f26078f3dfd4 Nicolin Chen 2023-08-01 392 if (WARN_ON(!hwpt))
588f26078f3dfd4 Nicolin Chen 2023-08-01 393 return;
cec938742db5c16 Nicolin Chen 2023-08-02 394 if (!iommufd_must_remove_rr(hwpt, new_hwpt, &keep_sw_msi))
588f26078f3dfd4 Nicolin Chen 2023-08-01 395 return;
cec938742db5c16 Nicolin Chen 2023-08-02 396 if (hwpt->user_managed)
cec938742db5c16 Nicolin Chen 2023-08-02 397 ioas = hwpt->parent->ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 398 else
cec938742db5c16 Nicolin Chen 2023-08-02 399 ioas = hwpt->ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 400 iopt_remove_reserved_iova(&ioas->iopt, idev->dev, keep_sw_msi);
588f26078f3dfd4 Nicolin Chen 2023-08-01 401 }
588f26078f3dfd4 Nicolin Chen 2023-08-01 402
588f26078f3dfd4 Nicolin Chen 2023-08-01 403 static bool iommufd_must_enforce_rr(struct iommufd_hw_pagetable *old_hwpt,
cec938742db5c16 Nicolin Chen 2023-08-02 404 struct iommufd_hw_pagetable *new_hwpt,
cec938742db5c16 Nicolin Chen 2023-08-02 405 bool *sw_msi_only)
588f26078f3dfd4 Nicolin Chen 2023-08-01 406 {
cec938742db5c16 Nicolin Chen 2023-08-02 407 struct iommufd_ioas *old_ioas, *new_ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 408
cec938742db5c16 Nicolin Chen 2023-08-02 409 if (new_hwpt->user_managed)
cec938742db5c16 Nicolin Chen 2023-08-02 410 new_ioas = new_hwpt->parent->ioas;
cec938742db5c16 Nicolin Chen 2023-08-02 411 else
cec938742db5c16 Nicolin Chen 2023-08-02 412 new_ioas = new_hwpt->ioas;
588f26078f3dfd4 Nicolin Chen 2023-08-01 413
588f26078f3dfd4 Nicolin Chen 2023-08-01 @414 if (!old_hwpt)
588f26078f3dfd4 Nicolin Chen 2023-08-01 415 old_ioas = NULL;
cec938742db5c16 Nicolin Chen 2023-08-02 416 else if (old_hwpt->user_managed)
cec938742db5c16 Nicolin Chen 2023-08-02 417 old_ioas = old_hwpt->parent->ioas;
588f26078f3dfd4 Nicolin Chen 2023-08-01 418 else
588f26078f3dfd4 Nicolin Chen 2023-08-01 419 old_ioas = old_hwpt->ioas;
588f26078f3dfd4 Nicolin Chen 2023-08-01 420
cec938742db5c16 Nicolin Chen 2023-08-02 421 if (new_hwpt->user_managed)
cec938742db5c16 Nicolin Chen 2023-08-02 422 *sw_msi_only = true;
cec938742db5c16 Nicolin Chen 2023-08-02 423 else
cec938742db5c16 Nicolin Chen 2023-08-02 424 *sw_msi_only = false;
cec938742db5c16 Nicolin Chen 2023-08-02 425
588f26078f3dfd4 Nicolin Chen 2023-08-01 426 /* When switching IOAS, enforcing the new IOAS is a must */
cec938742db5c16 Nicolin Chen 2023-08-02 427 if (old_ioas != new_ioas)
cec938742db5c16 Nicolin Chen 2023-08-02 428 return true;
cec938742db5c16 Nicolin Chen 2023-08-02 429 /*
cec938742db5c16 Nicolin Chen 2023-08-02 430 * Do not forget to enforce all regions when switching from a user-
cec938742db5c16 Nicolin Chen 2023-08-02 431 * managed hw_pagetable to its parent kernel-managed hw_pagetable.
cec938742db5c16 Nicolin Chen 2023-08-02 432 */
cec938742db5c16 Nicolin Chen 2023-08-02 @433 if (old_hwpt->user_managed && !new_hwpt->user_managed)
588f26078f3dfd4 Nicolin Chen 2023-08-01 434 return true;
cec938742db5c16 Nicolin Chen 2023-08-02 435 /*
cec938742db5c16 Nicolin Chen 2023-08-02 436 * Do not enforce in the remaining cases when IOAS isn't changed:
cec938742db5c16 Nicolin Chen 2023-08-02 437 * - switching from a kernel-managed hw_pagetable to another kernel-
cec938742db5c16 Nicolin Chen 2023-08-02 438 * managed hw_pagetable associated to the same IOAS. All the existing
cec938742db5c16 Nicolin Chen 2023-08-02 439 * reserved regions remain in the IOAS in this case.
cec938742db5c16 Nicolin Chen 2023-08-02 440 * - switching from a kernel-managed hw_pagetable to its associated
cec938742db5c16 Nicolin Chen 2023-08-02 441 * user-managed hw_pagetable. In this case, all the reserved regions
cec938742db5c16 Nicolin Chen 2023-08-02 442 * except IOMMU_RESV_SW_MSI will be removed from the reserved list.
cec938742db5c16 Nicolin Chen 2023-08-02 443 * - switching from a user-managed hw_pagetable to another user-managed
cec938742db5c16 Nicolin Chen 2023-08-02 444 * hw_pagetable associated to the same parent hw_pagetable (or IOAS).
cec938742db5c16 Nicolin Chen 2023-08-02 445 * In this case, IOMMU_RESV_SW_MSI is already enforced in the IOAS.
cec938742db5c16 Nicolin Chen 2023-08-02 446 */
588f26078f3dfd4 Nicolin Chen 2023-08-01 447 return false;
588f26078f3dfd4 Nicolin Chen 2023-08-01 448 }
588f26078f3dfd4 Nicolin Chen 2023-08-01 449
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2023-08-06 13:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-06 13:52 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-08-07 5:41 [yiliu1765-iommufd:wip/iommufd_nesting_08042023-yi 12/57] drivers/iommu/iommufd/device.c:358 iommufd_must_remove_rr() error: we previously assumed 'new_hwpt' could be null (see line 341) Dan Carpenter
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=202308062128.ASglP8pP-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--cc=oe-kbuild@lists.linux.dev \
/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.