From: Jia Yao <jia.yao@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Jia Yao <jia.yao@intel.com>,
Matthew Brost <matthew.brost@intel.com>,
Brian3 Nguyen <brian3.nguyen@intel.com>,
Alex Zuo <alex.zuo@intel.com>,
Shuicheng Lin <shuicheng.lin@intel.com>
Subject: [PATCH] drm/xe: Fix out-of-bounds field write in MI_STORE_DATA_IMM
Date: Fri, 23 May 2025 15:04:18 +0000 [thread overview]
Message-ID: <20250523150418.168362-1-jia.yao@intel.com> (raw)
According to Bspec, bits 0~9 of MI_STORE_DATA_IMM must not exceed 0x3FE.
The macro MI_SDI_NUM_QW(x) evaluates to 2 * x + 1, which means the
condition 2 * x + 1 <= 0x3FE must be satisfied. Therefore, the maximum
valid value for x is 0x1FE, not 0x1FF.
Bspec: 60246
Fixes: 9c44fd5f6e8a ("drm/xe: Add migrate layer functions for SVM support")
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Brian3 Nguyen <brian3.nguyen@intel.com>
Cc: Alex Zuo <alex.zuo@intel.com>
Suggested-by: Shuicheng Lin <shuicheng.lin@intel.com>
Signed-off-by: Jia Yao <jia.yao@intel.com>
---
drivers/gpu/drm/xe/xe_migrate.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index 8f8e9fdfb2a8..be8f05574850 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -1555,13 +1555,13 @@ static u32 pte_update_cmd_size(u64 size)
XE_WARN_ON(size > MAX_PREEMPTDISABLE_TRANSFER);
/*
* MI_STORE_DATA_IMM command is used to update page table. Each
- * instruction can update maximumly 0x1ff pte entries. To update
- * n (n <= 0x1ff) pte entries, we need:
+ * instruction can update maximumly 0x1fe pte entries. To update
+ * n (n <= 0x1fe) pte entries, we need:
* 1 dword for the MI_STORE_DATA_IMM command header (opcode etc)
* 2 dword for the page table's physical location
* 2*n dword for value of pte to fill (each pte entry is 2 dwords)
*/
- num_dword = (1 + 2) * DIV_U64_ROUND_UP(entries, 0x1ff);
+ num_dword = (1 + 2) * DIV_U64_ROUND_UP(entries, 0x1fe);
num_dword += entries * 2;
return num_dword;
@@ -1577,7 +1577,7 @@ static void build_pt_update_batch_sram(struct xe_migrate *m,
ptes = DIV_ROUND_UP(size, XE_PAGE_SIZE);
while (ptes) {
- u32 chunk = min(0x1ffU, ptes);
+ u32 chunk = min(0x1feU, ptes);
bb->cs[bb->len++] = MI_STORE_DATA_IMM | MI_SDI_NUM_QW(chunk);
bb->cs[bb->len++] = pt_offset;
--
2.34.1
next reply other threads:[~2025-05-23 15:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 15:04 Jia Yao [this message]
2025-05-23 15:54 ` ✓ CI.Patch_applied: success for drm/xe: Fix out-of-bounds field write in MI_STORE_DATA_IMM Patchwork
2025-05-23 15:54 ` ✓ CI.checkpatch: " Patchwork
2025-05-23 15:55 ` ✓ CI.KUnit: " Patchwork
2025-05-23 16:06 ` ✓ CI.Build: " Patchwork
2025-05-23 16:08 ` ✓ CI.Hooks: " Patchwork
2025-05-23 16:10 ` ✓ CI.checksparse: " Patchwork
2025-05-23 16:32 ` ✓ Xe.CI.BAT: " Patchwork
2025-05-24 9:52 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-27 13:07 ` [PATCH] " Maciej Patelczyk
2025-05-27 14:00 ` Maciej Patelczyk
2025-05-27 16:30 ` [PATCH v2] " Jia Yao
2025-05-27 17:38 ` Maciej Patelczyk
2025-05-27 18:25 ` Matthew Brost
2025-06-11 9:17 ` Lin, Shuicheng
2025-06-11 20:10 ` Lucas De Marchi
2025-06-26 17:08 ` Yao, Jia
2025-06-26 21:16 ` Lucas De Marchi
2025-06-26 21:19 ` Yao, Jia
2025-05-27 21:45 ` ✓ CI.Patch_applied: success for drm/xe: Fix out-of-bounds field write in MI_STORE_DATA_IMM (rev2) Patchwork
2025-05-27 21:45 ` ✗ CI.checkpatch: warning " Patchwork
2025-05-27 21:46 ` ✓ CI.KUnit: success " Patchwork
2025-05-27 21:50 ` ✗ CI.Build: failure " Patchwork
2025-05-28 7:54 ` ✓ CI.Patch_applied: success " Patchwork
2025-05-28 7:54 ` ✗ CI.checkpatch: warning " Patchwork
2025-05-28 7:56 ` ✓ CI.KUnit: success " Patchwork
2025-05-28 7:59 ` ✗ CI.Build: failure " Patchwork
2025-06-12 22:46 ` [PATCH v3] drm/xe: Fix out-of-bounds field write in MI_STORE_DATA_IMM Jia Yao
2025-06-13 7:29 ` ✗ CI.checkpatch: warning for drm/xe: Fix out-of-bounds field write in MI_STORE_DATA_IMM (rev3) Patchwork
2025-06-13 7:30 ` ✗ CI.KUnit: failure " 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=20250523150418.168362-1-jia.yao@intel.com \
--to=jia.yao@intel.com \
--cc=alex.zuo@intel.com \
--cc=brian3.nguyen@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=shuicheng.lin@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.