All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: himal.prasad.ghimiray@intel.com,
	Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
Subject: [PATCH v2 7/8] drm/xe/vm: validate large-page user BO bind alignment
Date: Wed,  1 Jul 2026 22:03:47 +0530	[thread overview]
Message-ID: <20260701163348.3432358-8-naresh.kumar.g@intel.com> (raw)
In-Reply-To: <20260701163348.3432358-1-naresh.kumar.g@intel.com>

Add VM bind validation for BOs that request 64K, 2M, or 1G pages.

When a BO is created with XE_BO_FLAG_NEEDS_64K, XE_BO_FLAG_NEEDS_2M,
or XE_BO_FLAG_NEEDS_1G, require the bind offset, virtual address, and
range to be aligned to the requested page size for map operations.
Skip these checks for unmap and unmap-all.

Also allow the corresponding VMA page table flags in the user-visible
VMA flag mask.

This prevents invalid bind requests for large-page BOs from reaching
later VM setup paths.

v2:(sashiko)
- add 64K alignment validation alongside 2M and 1G
  for user bindpaths
- keep large-page alignment checks skipped for
  UNMAP and UNMAP_ALL
- refine commit message wordings

Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
---
 drivers/gpu/drm/xe/xe_vm.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 50ca29a79533..3fc5f1db93d0 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -721,7 +721,10 @@ static void xe_vma_ops_incr_pt_update_ops(struct xe_vma_ops *vops, u8 tile_mask,
 	XE_VMA_DUMPABLE |		    \
 	XE_VMA_SYSTEM_ALLOCATOR |           \
 	DRM_GPUVA_SPARSE |		    \
-	XE_VMA_MADV_AUTORESET)
+	XE_VMA_MADV_AUTORESET |		    \
+	XE_VMA_PTE_64K |		    \
+	XE_VMA_PTE_2M  |		    \
+	XE_VMA_PTE_1G)
 
 static void xe_vm_populate_rebind(struct xe_vma_op *op, struct xe_vma *vma,
 				  u8 tile_mask)
@@ -3835,6 +3838,36 @@ static int xe_vm_bind_ioctl_validate_bo(struct xe_device *xe, struct xe_bo *bo,
 		}
 	}
 
+	if (bo->flags & XE_BO_FLAG_NEEDS_64K &&
+	    (op != DRM_XE_VM_BIND_OP_UNMAP &&
+	     op != DRM_XE_VM_BIND_OP_UNMAP_ALL)) {
+		if (XE_IOCTL_DBG(xe, obj_offset & (SZ_64K - 1)) ||
+		    XE_IOCTL_DBG(xe, addr & (SZ_64K - 1)) ||
+		    XE_IOCTL_DBG(xe, range & (SZ_64K - 1))) {
+			return -EINVAL;
+		}
+	}
+
+	if (bo->flags & XE_BO_FLAG_NEEDS_2M &&
+	    (op != DRM_XE_VM_BIND_OP_UNMAP &&
+	     op != DRM_XE_VM_BIND_OP_UNMAP_ALL)) {
+		if (XE_IOCTL_DBG(xe, obj_offset & (SZ_2M - 1)) ||
+		    XE_IOCTL_DBG(xe, addr & (SZ_2M - 1)) ||
+		    XE_IOCTL_DBG(xe, range & (SZ_2M - 1))) {
+			return -EINVAL;
+		}
+	}
+
+	if (bo->flags & XE_BO_FLAG_NEEDS_1G &&
+	    (op != DRM_XE_VM_BIND_OP_UNMAP &&
+	     op != DRM_XE_VM_BIND_OP_UNMAP_ALL)) {
+		if (XE_IOCTL_DBG(xe, obj_offset & (SZ_1G - 1)) ||
+		    XE_IOCTL_DBG(xe, addr & (SZ_1G - 1)) ||
+		    XE_IOCTL_DBG(xe, range & (SZ_1G - 1))) {
+			return -EINVAL;
+		}
+	}
+
 	coh_mode = xe_pat_index_get_coh_mode(xe, pat_index);
 	if (bo->cpu_caching) {
 		if (XE_IOCTL_DBG(xe, coh_mode == XE_COH_NONE &&
-- 
2.43.0


  parent reply	other threads:[~2026-07-01 16:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 16:33 [PATCH v2 0/8] drm/xe: add page size allocation mode control Nareshkumar Gollakoti
2026-07-01 16:33 ` [PATCH v2 1/8] drm/xe: add page size allocation control state to xe_device Nareshkumar Gollakoti
2026-07-01 16:33 ` [PATCH v2 2/8] drm/xe: add helper for multi page-size support Nareshkumar Gollakoti
2026-07-01 16:33 ` [PATCH v2 3/8] drm/xe/debugfs: add page size allocation mode knob Nareshkumar Gollakoti
2026-07-01 16:33 ` [PATCH v2 4/8] drm/xe: add 1G BO page-size alignment flag Nareshkumar Gollakoti
2026-07-01 16:33 ` [PATCH v2 5/8] drm/xe: apply debug page-size policy to user BO creation Nareshkumar Gollakoti
2026-07-01 16:33 ` [PATCH v2 6/8] drm/xe/vm: apply debug page-size policy to VMA map flags Nareshkumar Gollakoti
2026-07-01 16:33 ` Nareshkumar Gollakoti [this message]
2026-07-01 16:33 ` [PATCH v2 8/8] drm/xe/pt: allow selecting the bind leaf PTE level Nareshkumar Gollakoti
2026-07-01 17:19 ` ✓ CI.KUnit: success for drm/xe: add page size allocation mode control Patchwork

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=20260701163348.3432358-8-naresh.kumar.g@intel.com \
    --to=naresh.kumar.g@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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.