[PATCH v6 5/7] drm/xe/vf: Add bounds checking for queried GGTT base and size
Satyanarayana K V P <[email protected]>
| Newsgroups | org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
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]> --- V5 -> V6: - Updated error codes for unaligned GGTT base and size (Michal W). - Fixed review comments (Michal W). V4 -> V5: - New commit. --- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 13 +++++++++++++ 1 file changed, 13 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..d805c064377c 100644 --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c @@ -488,6 +488,7 @@ u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt) static int vf_get_ggtt_info(struct xe_gt *gt) { + u64 alignment = xe_vram_alignment(gt_to_xe(gt)); struct xe_tile *tile = gt_to_tile(gt); struct xe_guc *guc = >->uc.guc; u64 start, size, ggtt_size; @@ -526,6 +527,18 @@ static int vf_get_ggtt_info(struct xe_gt *gt) return -EREMCHG; } + if (!IS_ALIGNED(start, alignment)) { + xe_gt_sriov_err(gt, "Unaligned GGTT base: %llu, expected %llu\n", + start, ALIGN(start, alignment)); + return -EINVAL; + } + + if (!IS_ALIGNED(size, alignment)) { + xe_gt_sriov_err(gt, "Unaligned GGTT size %llu, expected %llu\n", + size, ALIGN(size, alignment)); + return -EINVAL; + } + xe_gt_sriov_dbg_verbose(gt, "GGTT %#llx-%#llx = %lluK\n", start, start + size - 1, size / SZ_1K); -- 2.53.0