Re: [PATCH v5 4/6] drm/xe/vf: Add bounds checking for queried GGTT base and size
Michal Wajdeczko <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
On 8/10/2026 12:14 PM, Satyanarayana K V P wrote: > Add explicit bounds checks for GGTT base and size which can detect > and reject invalid configuration data from a misconfigured or > malfunctioning PF, preventing protocol violations and protecting VF > initialization. > > Signed-off-by: Satyanarayana K V P <[email protected]> > Cc: Michal Wajdeczko <[email protected]> > --- > V4 -> V5: > - New commit. > --- > drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > index 81d68fe5ad7c..65e48f135801 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > @@ -486,8 +486,16 @@ u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt) > return value; > } > > +static u64 vf_get_ggtt_alignment(struct xe_gt *gt) > +{ > + struct xe_device *xe = gt_to_xe(gt); > + > + return IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K; > +} I guess it's time to extract this logic to some common helper (maybe in xe_ggtt.c or xe_device.c) as we repeat that in: xe_gt_sriov_pf_config.c:446: return IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K; xe_ggtt.c:423: if (IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K) ggtt->flags |= XE_GGTT_FLAGS_64K; display/xe_initial_plane.c:48: u64 page_size = xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K; xe_bo.c-4057- u32 page_size = max_t(u32, PAGE_SIZE, xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K); xe_query.c-291 mem_regions->mem_regions[mem_regions->num_mem_regions].min_page_size = xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : PAGE_SIZE; xe_query.c-357- config->info[DRM_XE_QUERY_CONFIG_MIN_ALIGNMENT] = xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K; ... > + > static int vf_get_ggtt_info(struct xe_gt *gt) > { > + u64 alignment = vf_get_ggtt_alignment(gt); > struct xe_tile *tile = gt_to_tile(gt); > struct xe_guc *guc = >->uc.guc; > u64 start, size, ggtt_size; > @@ -526,6 +534,18 @@ static int vf_get_ggtt_info(struct xe_gt *gt) > return -EREMCHG; > } > > + if (size % alignment) { IS_ALIGNED(size, alignment) > + xe_gt_sriov_err(gt, "Unexpected GGTT alignment for size: %llu != %llu\n", "Unaligned GGTT size (%llu != %llu)" or "Unaligned GGTT size %llu, expected %llu" > + size, (size / alignment) * alignment); size, ALIGN(size, alignment) > + return -EREMCHG; > + } > + > + if (start % alignment) { > + xe_gt_sriov_err(gt, "Unexpected GGTT alignment for base: %llu != %llu\n", > + start, (start / alignment) * alignment); > + return -EREMCHG; ditto and maybe check base first? > + } > + > xe_gt_sriov_dbg_verbose(gt, "GGTT %#llx-%#llx = %lluK\n", > start, start + size - 1, size / SZ_1K); >