]> git.hungrycats.org Git - linux/commitdiff
drm/xe/mmio: Add check for minimal BAR size
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 22 Jun 2026 13:23:39 +0000 (15:23 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 23 Jun 2026 17:15:16 +0000 (19:15 +0200)
We initialized the root tile's xe_mmio structure with a new size
of 4MiB without sanity checks to see if mapped GTTMMADR_BAR was
actually at least that size. Check BAR size against first 16MiB,
which is expected minimum BAR size for the one-tile platforms.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patch.msgid.link/20260622132342.19600-4-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_mmio.c

index fce890b6410c78b20fb7866c35ec9846218b7957..8dd818e1184c89142cffb1a90511bb5c0193f7f2 100644 (file)
@@ -101,13 +101,18 @@ int xe_mmio_probe_early(struct xe_device *xe)
        struct xe_tile *root_tile = xe_device_get_root_tile(xe);
        struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
 
-       xe->mmio.size = pci_resource_len(pdev, GTTMMADR_BAR);
        xe->mmio.regs = pcim_iomap(pdev, GTTMMADR_BAR, 0);
        if (!xe->mmio.regs) {
                xe_err(xe, "Failed to map GTTMMADR_BAR\n");
                return -EIO;
        }
 
+       xe->mmio.size = pci_resource_len(pdev, GTTMMADR_BAR);
+       if (xe->mmio.size < SZ_16M) {
+               xe_err(xe, "GTTMMADR_BAR is too small: %zu\n", xe->mmio.size);
+               return -EIO;
+       }
+
        /* Setup first tile; other tiles (if present) will be setup later. */
        xe_mmio_init(&root_tile->mmio, root_tile, xe->mmio.regs, SZ_4M);