On 9/16/2026 9:44 AM, David Marchand wrote:
On Thu, 10 Sept 2026 at 14:56, Anatoly Burakov
<[email protected]> wrote:
@@ -500,7 +507,8 @@ rte_dpaa2_get_iommu_class(void)
                 return RTE_IOVA_DC;

         /* check if all devices on the bus support Virtual addressing or not */
-       if (fslmc_all_device_support_iova() != 0 && 
dev_vfio_noiommu_is_enabled() == 0)
+       if (fslmc_all_device_support_iova() != 0 &&
+                       dev_vfio_get_iommu_mode() == DEV_VFIO_IOMMU_MODE_UNSAFE)
                 return RTE_IOVA_VA;

         return RTE_IOVA_PA;

IA flagged this part:

In `fslmc_bus.c`, the condition changed from:
```c
/* Old */
if (fslmc_all_device_support_iova() != 0 && dev_vfio_noiommu_is_enabled() == 0)
     return RTE_IOVA_VA;

/* New */
if (fslmc_all_device_support_iova() != 0 &&
         dev_vfio_get_iommu_mode() == DEV_VFIO_IOMMU_MODE_UNSAFE)
     return RTE_IOVA_VA;
```

The old code returned `RTE_IOVA_VA` when NOIOMMU was **disabled** (==
0), but the new code returns `RTE_IOVA_VA` when IOMMU mode is
**UNSAFE** (i.e., NOIOMMU is enabled).

Looking at `dev_vfio_noiommu_is_enabled()`:
```c
int
dev_vfio_noiommu_is_enabled(void)
{
     return vfio_global_cfg.iommu_mode == DEV_VFIO_IOMMU_MODE_UNSAFE;
}
```

So:
- Old: `dev_vfio_noiommu_is_enabled() == 0` → NOIOMMU is NOT enabled →
IOMMU is SAFE
- New: `dev_vfio_get_iommu_mode() == DEV_VFIO_IOMMU_MODE_UNSAFE` →
NOIOMMU IS enabled

**This is an inverted condition.** The old code returned `RTE_IOVA_VA`
when IOMMU was safe (NOIOMMU disabled), but the new code returns
`RTE_IOVA_VA` when IOMMU is unsafe (NOIOMMU enabled). This appears to
be a correctness bug that will change the IOVA mode selection
behavior.

**Suggested fix:** The new condition should likely be:
```c
if (fslmc_all_device_support_iova() != 0 &&
         dev_vfio_get_iommu_mode() != DEV_VFIO_IOMMU_MODE_UNSAFE)
     return RTE_IOVA_VA;
```

Or if the intent was to check for safe mode:
```c
if (fslmc_all_device_support_iova() != 0 &&
         dev_vfio_get_iommu_mode() == DEV_VFIO_IOMMU_MODE_SAFE)
     return RTE_IOVA_VA;
```


Yep, a typo.

--
Thanks,
Anatoly

Reply via email to