drm/xe/ppgtt: clear the scratch page
authorMatthew Auld <matthew.auld@intel.com>
Thu, 22 Dec 2022 14:09:02 +0000 (14:09 +0000)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:27:44 +0000 (18:27 -0500)
We need to ensure we don't leak the contents to userspace.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_pt.c

index 688bc4b56294c1c8d00146ddd11d9f8b327cf1a8..d7fb1ddb8789cfa114b1883e0a59a0401828f621 100644 (file)
@@ -333,14 +333,16 @@ int xe_pt_create_scratch(struct xe_device *xe, struct xe_gt *gt,
        u8 id = gt->info.id;
        int i;
 
-       vm->scratch_bo[id] = xe_bo_create(xe, gt, vm, SZ_4K,
-                                         ttm_bo_type_kernel,
-                                         XE_BO_CREATE_VRAM_IF_DGFX(gt) |
-                                         XE_BO_CREATE_IGNORE_MIN_PAGE_SIZE_BIT |
-                                         XE_BO_CREATE_PINNED_BIT);
+       vm->scratch_bo[id] = xe_bo_create_pin_map(xe, gt, vm, SZ_4K,
+                                                 ttm_bo_type_kernel,
+                                                 XE_BO_CREATE_VRAM_IF_DGFX(gt) |
+                                                 XE_BO_CREATE_IGNORE_MIN_PAGE_SIZE_BIT |
+                                                 XE_BO_CREATE_PINNED_BIT);
        if (IS_ERR(vm->scratch_bo[id]))
                return PTR_ERR(vm->scratch_bo[id]);
-       xe_bo_pin(vm->scratch_bo[id]);
+
+       xe_map_memset(vm->xe, &vm->scratch_bo[id]->vmap, 0, 0,
+                     vm->scratch_bo[id]->size);
 
        for (i = 0; i < vm->pt_root[id]->level; i++) {
                vm->scratch_pt[id][i] = xe_pt_create(vm, gt, i);