<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="moz-cite-prefix">On 11/21/2024 15:18, Marcin Bernatowicz
wrote:<br>
</div>
<blockquote type="cite" cite="mid:20241121141851.631877-5-marcin.bernatowicz@linux.intel.com">
<pre wrap="" class="moz-quote-pre">Update range-checking logic to iterate only within valid PTE offsets
based on MAX_WOPCM_SIZE and GUC_GGTT_TOP.
Closes: <a class="moz-txt-link-freetext" href="https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3507">https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3507</a>
Signed-off-by: Marcin Bernatowicz <a class="moz-txt-link-rfc2396E" href="mailto:marcin.bernatowicz@linux.intel.com"><marcin.bernatowicz@linux.intel.com></a>
Cc: Adam Miszczak <a class="moz-txt-link-rfc2396E" href="mailto:adam.miszczak@linux.intel.com"><adam.miszczak@linux.intel.com></a>
Cc: C V Narasimha <a class="moz-txt-link-rfc2396E" href="mailto:narasimha.c.v@intel.com"><narasimha.c.v@intel.com></a>
Cc: Jakub Kolakowski <a class="moz-txt-link-rfc2396E" href="mailto:jakub1.kolakowski@intel.com"><jakub1.kolakowski@intel.com></a>
Cc: K V P Satyanarayana <a class="moz-txt-link-rfc2396E" href="mailto:satyanarayana.k.v.p@intel.com"><satyanarayana.k.v.p@intel.com></a>
Cc: Lukasz Laguna <a class="moz-txt-link-rfc2396E" href="mailto:lukasz.laguna@intel.com"><lukasz.laguna@intel.com></a>
Cc: Michał Wajdeczko <a class="moz-txt-link-rfc2396E" href="mailto:michal.wajdeczko@intel.com"><michal.wajdeczko@intel.com></a>
Cc: Michał Winiarski <a class="moz-txt-link-rfc2396E" href="mailto:michal.winiarski@intel.com"><michal.winiarski@intel.com></a>
Cc: Piotr Piórkowski <a class="moz-txt-link-rfc2396E" href="mailto:piotr.piorkowski@intel.com"><piotr.piorkowski@intel.com></a>
Cc: Tomasz Lis <a class="moz-txt-link-rfc2396E" href="mailto:tomasz.lis@intel.com"><tomasz.lis@intel.com></a>
---
lib/xe/xe_sriov_provisioning.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
index d448a53d8..67ae9cf54 100644
--- a/lib/xe/xe_sriov_provisioning.c
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -39,6 +39,10 @@ const char *xe_sriov_shared_res_to_string(enum xe_sriov_shared_res res)
#define PRE_1250_IP_VER_GGTT_PTE_VFID_MASK GENMASK_ULL(4, 2)
#define GGTT_PTE_VFID_MASK GENMASK_ULL(11, 2)
#define GGTT_PTE_VFID_SHIFT 2
+#define GUC_GGTT_TOP 0xFEE00000
+#define MAX_WOPCM_SIZE SZ_8M
+#define START_PTE_OFFSET (MAX_WOPCM_SIZE / SZ_4K * sizeof(xe_ggtt_pte_t))
+#define MAX_PTE_OFFSET (GUC_GGTT_TOP / SZ_4K * sizeof(xe_ggtt_pte_t))
static uint64_t get_vfid_mask(int fd)
{
@@ -112,7 +116,8 @@ int xe_sriov_find_ggtt_provisioned_pte_offsets(int pf_fd, int gt, struct xe_mmio
*ranges = NULL;
*nr_ranges = 0;
- for (uint32_t offset = 0; offset < SZ_8M; offset += sizeof(xe_ggtt_pte_t)) {
+ for (uint32_t offset = START_PTE_OFFSET; offset < MAX_PTE_OFFSET;
+ offset += sizeof(xe_ggtt_pte_t)) {
pte = xe_mmio_ggtt_read(mmio, gt, offset);
vf_id = (pte & vfid_mask) >> GGTT_PTE_VFID_SHIFT;
</pre>
</blockquote>
<br>
<br>
LGTM,<br>
<span lang="en-US">Reviewed-by: </span><span lang="pl">L</span><span lang="en-US">ukasz </span><span lang="pl">L</span><span lang="en-US">aguna <a class="moz-txt-link-rfc2396E" href="mailto:lukasz.laguna@intel.com"><lukasz.laguna@intel.com></a><br>
<br>
<br>
</span><span lang="en-US"></span><span style="white-space: pre-wrap">
</span>
</body>
</html>