From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Tejas Upadhyay" <tejas.upadhyay@intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Ilia Levi" <ilia.levi@intel.com>
Subject: [PATCH v5 7/8] drm/xe/mmio_gem: reject VM_EXEC and drop VM_DONTCOPY
Date: Tue, 8 Sep 2026 17:50:54 +0100 [thread overview]
Message-ID: <20260908165046.1393557-17-matthew.auld@intel.com> (raw)
In-Reply-To: <20260908165046.1393557-10-matthew.auld@intel.com>
Hardware MMIO registers should never be executable; reject VM_EXEC
at mmap time and clear VM_MAYEXEC to prevent later mprotect attempts.
Also drop VM_DONTCOPY so that child processes across fork() can
inherit the mapping and lazily fault in the PFNs, matching standard
DRM GEM semantics and making the existing drm_gem_vm_open() callback
functional.
This aligns with existing PCI_BARRIER, which will use this in the next
patch. We don't want any noticeable behaviour change there, since this
will be user visible. This will also be the first user.
Assisted-by: LLM
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Ilia Levi <ilia.levi@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/xe/xe_mmio_gem.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_mmio_gem.c b/drivers/gpu/drm/xe/xe_mmio_gem.c
index 5ffe03d36190..3cdc9538957d 100644
--- a/drivers/gpu/drm/xe/xe_mmio_gem.c
+++ b/drivers/gpu/drm/xe/xe_mmio_gem.c
@@ -177,9 +177,12 @@ static int xe_mmio_gem_mmap(struct drm_gem_object *base, struct vm_area_struct *
if ((vma->vm_flags & VM_SHARED) == 0)
return -EINVAL;
+ if (vma->vm_flags & VM_EXEC)
+ return -EINVAL;
+
vma->vm_page_prot = pgprot_noncached(vma_get_page_prot(vma));
- vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP |
- VM_DONTCOPY | VM_NORESERVE);
+ vm_flags_mod(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP |
+ VM_NORESERVE, VM_MAYEXEC);
/* Defer actual mapping to the fault handler. */
return 0;
--
2.55.0
next prev parent reply other threads:[~2026-09-08 16:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 16:50 [PATCH v5 0/8] drm/xe/mmio_gem: fix fault handler and destroy path Matthew Auld
2026-09-08 16:50 ` [PATCH v5 1/8] drm/xe/mmio_gem: forbid VMA split Matthew Auld
2026-09-08 16:50 ` [PATCH v5 2/8] drm/xe/mmio_gem: use write-back mapping for dummy page Matthew Auld
2026-09-08 16:50 ` [PATCH v5 3/8] drm/xe/mmio_gem: simplify fault handler loop Matthew Auld
2026-09-08 16:50 ` [PATCH v5 4/8] drm/xe/mmio_gem: Revoke drm_vma_node on xe_mmio_gem destroy Matthew Auld
2026-09-08 16:50 ` [PATCH v5 5/8] drm/xe/mmio_gem: cache the dummy page per object Matthew Auld
2026-09-08 16:50 ` [PATCH v5 6/8] drm/xe/mmio_gem: fix destroy flow Matthew Auld
2026-09-08 17:12 ` sashiko-bot
2026-09-08 17:23 ` Matthew Auld
2026-09-08 16:50 ` Matthew Auld [this message]
2026-09-08 16:50 ` [PATCH v5 8/8] drm/xe: convert PCI barrier mmap to use xe_mmio_gem Matthew Auld
2026-09-08 17:07 ` Thomas Hellström
2026-09-08 17:23 ` sashiko-bot
2026-09-08 16:59 ` ✓ CI.KUnit: success for drm/xe/mmio_gem: fix fault handler and destroy path (rev5) Patchwork
2026-09-08 17:36 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-08 22:52 ` ✓ Xe.CI.FULL: " 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=20260908165046.1393557-17-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=ilia.levi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=tejas.upadhyay@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/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.