From patchwork Tue Oct 31 10:23:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10036021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D233F600C5 for ; Wed, 1 Nov 2017 08:39:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB7128B5E for ; Wed, 1 Nov 2017 08:39:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A62AA28B60; Wed, 1 Nov 2017 08:39:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 12C1B28B5D for ; Wed, 1 Nov 2017 08:39:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D35716E6DD; Wed, 1 Nov 2017 08:38:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id E54A66E554 for ; Tue, 31 Oct 2017 10:23:33 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id y9so15407478wrb.2 for ; Tue, 31 Oct 2017 03:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ZQn2KvKGJzuICSWvrfZy0/0CKz4X6vmrxRfCnWU+FtY=; b=LiepoqaNCDpY+COhG5htvi2MJZCA62tQYpIDhCAcOtmMTGIba8JMmRDI65GhKOyflj LkTrEvdXbh5BWFudz1b6tIF4I4RTeC5eUB8WXA3XdftaJNbYxm6Ol66fyvQ06CoF1EAF uHokg2x3V2VoQNOWd2Ksf4xUxsWkdCBSOuYT7TGqcjLXIamOD+X00LfZBnj8pZSUQ3Yq kKmAl/kjQOuIti/a7D9ixGZacDy1kSbpOT7OlqGk7qtbboRcdDW2mnvXwRCIIqQRiLQ6 tT2cROCqwLQkvM/nAKAySeZ4bqpUUuvRnS4XT5Ollmf4vjqWPiDFN/FQEM/PP5noYOll z6Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZQn2KvKGJzuICSWvrfZy0/0CKz4X6vmrxRfCnWU+FtY=; b=h4xqyxft9fJCReEe562QlSargpYNZui60Zw8yf/TnXR1Ui154DohWs4kFg0Myt2M14 z4WUXETr/NdYcMZKE20XceSZkpudZXfy2P7Qk9ATBI0DOJt5uMXqVIo+EHtTT2Ju9VW5 TB6wVE1jTOPirdIGObHw8m2np+grenl/dGKjItIJC53aEIPVrLiRMHfC3Ub1J1r2fTdI /2z8G8aVVUhENgqSO+3sq9gQXqG11lO9q/LLep5iISMZdATs+bXAi2zQza1Ow36C32jN fnsegU7gM4qsRWRCzAYVFQyPrN7VQD75FROmOrw1yXXdD7l2Jxf24YNmIAMAeF8xvllf RObw== X-Gm-Message-State: AMCzsaUj0B2+QkGnOyOrrTuFunM5+73eVce83Uq9yYAsd032S6r5gv9H 40uEnrFb9z37x2UgP/1KOziDKQ== X-Google-Smtp-Source: ABhQp+Q6joPAkft1HeRy/06TEreIxC4XWhd0VQ1+Jc4sbh26wFmcCVKhD1efF4Ka0av12B8x1q7DfQ== X-Received: by 10.223.183.75 with SMTP id n11mr1414524wre.185.1509445412345; Tue, 31 Oct 2017 03:23:32 -0700 (PDT) Received: from t460p.intel ([95.146.151.224]) by smtp.gmail.com with ESMTPSA id q4sm1116493wmd.19.2017.10.31.03.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 03:23:31 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Subject: [PATCH 1/2] drm/i915: Reject unknown syncobj flags Date: Tue, 31 Oct 2017 10:23:25 +0000 Message-Id: <20171031102326.9738-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.5 X-Mailman-Approved-At: Wed, 01 Nov 2017 08:38:18 +0000 Cc: Tvrtko Ursulin , David Airlie , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , dri-devel@lists.freedesktop.org, Jason Ekstrand , Rodrigo Vivi , tursulin@ursulin.net X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin We have to reject unknown flags for uAPI considerations, and also because the curent implementation limits their i915 storage space to two bits. v2: (Chris Wilson) * Fix fail in ABI check. * Added unknown flags and BUILD_BUG_ON. v3: * Use ARCH_KMALLOC_MINALIGN instead of alignof. (Chris Wilson) Signed-off-by: Tvrtko Ursulin Fixes: cf6e7bac6357 ("drm/i915: Add support for drm syncobjs") Cc: Jason Ekstrand Cc: Chris Wilson Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: David Airlie Cc: intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 8 ++++++++ include/uapi/drm/i915_drm.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 3d7190764f10..a53be7d01055 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -2100,6 +2100,11 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args, goto err; } + if (fence.flags & __I915_EXEC_FENCE_UNKNOWN_FLAGS) { + err = -EINVAL; + goto err; + } + syncobj = drm_syncobj_find(file, fence.handle); if (!syncobj) { DRM_DEBUG("Invalid syncobj handle provided\n"); @@ -2107,6 +2112,9 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args, goto err; } + BUILD_BUG_ON(~(ARCH_KMALLOC_MINALIGN - 1) & + ~__I915_EXEC_FENCE_UNKNOWN_FLAGS); + fences[n] = ptr_pack_bits(syncobj, fence.flags, 2); } diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 125bde7d9504..ac3c6503ca27 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -839,6 +839,7 @@ struct drm_i915_gem_exec_fence { #define I915_EXEC_FENCE_WAIT (1<<0) #define I915_EXEC_FENCE_SIGNAL (1<<1) +#define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1)) __u32 flags; };