unsigned long pg_size;
        int ret = 0;
 
-       if (!iommu_is_dma_domain(domain))
-               return 0;
-
-       BUG_ON(!domain->pgsize_bitmap);
-
-       pg_size = 1UL << __ffs(domain->pgsize_bitmap);
+       pg_size = domain->pgsize_bitmap ? 1UL << __ffs(domain->pgsize_bitmap) : 0;
        INIT_LIST_HEAD(&mappings);
 
+       if (WARN_ON_ONCE(iommu_is_dma_domain(domain) && !pg_size))
+               return -EINVAL;
+
        iommu_get_resv_regions(dev, &mappings);
 
        /* We need to consider overlapping regions for different devices */
                dma_addr_t start, end, addr;
                size_t map_size = 0;
 
-               start = ALIGN(entry->start, pg_size);
-               end   = ALIGN(entry->start + entry->length, pg_size);
+               if (entry->type == IOMMU_RESV_DIRECT)
+                       dev->iommu->require_direct = 1;
 
-               if (entry->type != IOMMU_RESV_DIRECT &&
-                   entry->type != IOMMU_RESV_DIRECT_RELAXABLE)
+               if ((entry->type != IOMMU_RESV_DIRECT &&
+                    entry->type != IOMMU_RESV_DIRECT_RELAXABLE) ||
+                   !iommu_is_dma_domain(domain))
                        continue;
 
+               start = ALIGN(entry->start, pg_size);
+               end   = ALIGN(entry->start + entry->length, pg_size);
+
                for (addr = start; addr <= end; addr += pg_size) {
                        phys_addr_t phys_addr;
 
 {
        int ret;
 
+       /*
+        * If the device requires IOMMU_RESV_DIRECT then we cannot allow
+        * the blocking domain to be attached as it does not contain the
+        * required 1:1 mapping. This test effectively excludes the device
+        * being used with iommu_group_claim_dma_owner() which will block
+        * vfio and iommufd as well.
+        */
+       if (dev->iommu->require_direct &&
+           (new_domain->type == IOMMU_DOMAIN_BLOCKED ||
+            new_domain == group->blocking_domain)) {
+               dev_warn(dev,
+                        "Firmware has requested this device have a 1:1 IOMMU mapping, rejecting configuring the device without a 1:1 mapping. Contact your platform vendor.\n");
+               return -EINVAL;
+       }
+
        if (dev->iommu->attach_deferred) {
                if (new_domain == group->default_domain)
                        return 0;
 
  * @priv:       IOMMU Driver private data
  * @max_pasids:  number of PASIDs this device can consume
  * @attach_deferred: the dma domain attachment is deferred
+ * @require_direct: device requires IOMMU_RESV_DIRECT regions
  *
  * TODO: migrate other per device data pointers under iommu_dev_data, e.g.
  *     struct iommu_group      *iommu_group;
        void                            *priv;
        u32                             max_pasids;
        u32                             attach_deferred:1;
+       u32                             require_direct:1;
 };
 
 int iommu_device_register(struct iommu_device *iommu,