[Intel-gfx] [PATCH] drm/i915: Fix cmd parser desc matching with masks
Chris Wilson
chris.p.wilson at intel.com
Mon Aug 17 20:07:06 UTC 2020
Quoting Mika Kuoppala (2020-08-17 20:59:26)
> Our variety of defined gpu commands have the actual
> command id field and possibly length and flags applied.
>
> We did start to apply the mask during initialization of
> the cmd descriptors but forgot to also apply it on comparisons.
>
> Fix comparisons in order to properly deny access with
> associated commands.
>
> v2: fix lri with correct mask (Chris)
>
> References: 926abff21a8f ("drm/i915/cmdparser: Ignore Length operands during command matching")
> Reported-by: Nicolai Stange <nstange at suse.de>
> Cc: stable at vger.kernel.org # v5.4+
> Cc: Miroslav Benes <mbenes at suse.cz>
> Cc: Takashi Iwai <tiwai at suse.de>
> Cc: Tyler Hicks <tyhicks at canonical.com>
> Cc: Jon Bloomfield <jon.bloomfield at intel.com>
> Cc: Chris Wilson <chris.p.wilson at intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_cmd_parser.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_cmd_parser.c b/drivers/gpu/drm/i915/i915_cmd_parser.c
> index 372354d33f55..5ac4a999f05a 100644
> --- a/drivers/gpu/drm/i915/i915_cmd_parser.c
> +++ b/drivers/gpu/drm/i915/i915_cmd_parser.c
> @@ -1204,6 +1204,12 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj,
> return dst;
> }
>
> +static inline bool cmd_desc_is(const struct drm_i915_cmd_descriptor * const desc,
> + const u32 cmd)
> +{
> + return desc->cmd.value == (cmd & desc->cmd.mask);
We could observe that the mask we need is always -1u << 23, we do use
that info already for the cmd hashing, but more important is that we are
consistent with our use of desc->cmd.mask everywhere else.
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the Intel-gfx
mailing list