Skip to content

Commit c12c729

Browse files
committed
drm/xe/vf: Add sanity check for GGTT configuration
The VF GGTT configuration was prepared by the PF, which should be trusted, was obtained from the GuC, which likely already did some sanity checks too, but since it's a received data, we should have our own sanity checks to detect early any misconfiguration. Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com> Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com> Link: https://lore.kernel.org/r/20250602103325.549-4-michal.wajdeczko@intel.com
1 parent eb9b347 commit c12c729

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/gpu/drm/xe/xe_tile_sriov_vf.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "xe_ggtt.h"
1212
#include "xe_gt_sriov_vf.h"
1313
#include "xe_sriov.h"
14+
#include "xe_sriov_printk.h"
1415
#include "xe_tile_sriov_vf.h"
1516
#include "xe_wopcm.h"
1617

@@ -44,6 +45,7 @@ int xe_tile_sriov_vf_balloon_ggtt_locked(struct xe_tile *tile)
4445
u64 ggtt_base = xe_gt_sriov_vf_ggtt_base(tile->primary_gt);
4546
u64 ggtt_size = xe_gt_sriov_vf_ggtt(tile->primary_gt);
4647
struct xe_device *xe = tile_to_xe(tile);
48+
u64 wopcm = xe_wopcm_size(xe);
4749
u64 start, end;
4850
int err;
4951

@@ -66,7 +68,14 @@ int xe_tile_sriov_vf_balloon_ggtt_locked(struct xe_tile *tile)
6668
* |<--- balloon[0] --->|<-- VF -->|<-- balloon[1] ->|
6769
*/
6870

69-
start = xe_wopcm_size(xe);
71+
if (ggtt_base < wopcm || ggtt_base > GUC_GGTT_TOP ||
72+
ggtt_size > GUC_GGTT_TOP - ggtt_base) {
73+
xe_sriov_err(xe, "tile%u: Invalid GGTT configuration: %#llx-%#llx\n",
74+
tile->id, ggtt_base, ggtt_base + ggtt_size - 1);
75+
return -ERANGE;
76+
}
77+
78+
start = wopcm;
7079
end = ggtt_base;
7180
if (end != start) {
7281
err = xe_ggtt_node_insert_balloon_locked(tile->sriov.vf.ggtt_balloon[0],

0 commit comments

Comments
 (0)