Skip to content

Commit 4415764

Browse files
drm/i915: Disable Secure Batches for gen6+
Retroactively stop reporting support for secure batches through the api for gen6+ so that older binaries trigger the fallback path instead. Older binaries use secure batches pre gen6 to access resources that are not available to normal usermode processes. However, all known userspace explicitly checks for HAS_SECURE_BATCHES before relying on the secure batch feature. Since there are no known binaries relying on this for newer gens we can kill secure batches from gen6, via I915_PARAM_HAS_SECURE_BATCHES. v2: rebase (Mika) v3: rebase (Mika) Signed-off-by: Jon Bloomfield <[email protected]> Cc: Tony Luck <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: Tyler Hicks <[email protected]> Signed-off-by: Mika Kuoppala <[email protected]> Reviewed-by: Chris Wilson <[email protected]>
1 parent 0a2f661 commit 4415764

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
24212421
struct drm_i915_gem_exec_object2 *exec,
24222422
struct drm_syncobj **fences)
24232423
{
2424+
struct drm_i915_private *i915 = to_i915(dev);
24242425
struct i915_execbuffer eb;
24252426
struct dma_fence *in_fence = NULL;
24262427
struct dma_fence *exec_fence = NULL;
@@ -2432,7 +2433,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
24322433
BUILD_BUG_ON(__EXEC_OBJECT_INTERNAL_FLAGS &
24332434
~__EXEC_OBJECT_UNKNOWN_FLAGS);
24342435

2435-
eb.i915 = to_i915(dev);
2436+
eb.i915 = i915;
24362437
eb.file = file;
24372438
eb.args = args;
24382439
if (DBG_FORCE_RELOC || !(args->flags & I915_EXEC_NO_RELOC))
@@ -2452,8 +2453,15 @@ i915_gem_do_execbuffer(struct drm_device *dev,
24522453

24532454
eb.batch_flags = 0;
24542455
if (args->flags & I915_EXEC_SECURE) {
2456+
if (INTEL_GEN(i915) >= 11)
2457+
return -ENODEV;
2458+
2459+
/* Return -EPERM to trigger fallback code on old binaries. */
2460+
if (!HAS_SECURE_BATCHES(i915))
2461+
return -EPERM;
2462+
24552463
if (!drm_is_current_master(file) || !capable(CAP_SYS_ADMIN))
2456-
return -EPERM;
2464+
return -EPERM;
24572465

24582466
eb.batch_flags |= I915_DISPATCH_SECURE;
24592467
}

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,6 +2078,7 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
20782078
#define HAS_LLC(dev_priv) (INTEL_INFO(dev_priv)->has_llc)
20792079
#define HAS_SNOOP(dev_priv) (INTEL_INFO(dev_priv)->has_snoop)
20802080
#define HAS_EDRAM(dev_priv) ((dev_priv)->edram_size_mb)
2081+
#define HAS_SECURE_BATCHES(dev_priv) (INTEL_GEN(dev_priv) < 6)
20812082
#define HAS_WT(dev_priv) ((IS_HASWELL(dev_priv) || \
20822083
IS_BROADWELL(dev_priv)) && HAS_EDRAM(dev_priv))
20832084

drivers/gpu/drm/i915/i915_getparam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int i915_getparam_ioctl(struct drm_device *dev, void *data,
6262
value = !!(i915->caps.scheduler & I915_SCHEDULER_CAP_SEMAPHORES);
6363
break;
6464
case I915_PARAM_HAS_SECURE_BATCHES:
65-
value = capable(CAP_SYS_ADMIN);
65+
value = HAS_SECURE_BATCHES(i915) && capable(CAP_SYS_ADMIN);
6666
break;
6767
case I915_PARAM_CMD_PARSER_VERSION:
6868
value = i915_cmd_parser_get_version(i915);

0 commit comments

Comments
 (0)