From patchwork Fri Oct 27 14:12:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10032195 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 27B936039A for ; Mon, 30 Oct 2017 08:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14A55285CE for ; Mon, 30 Oct 2017 08:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 064302874A; Mon, 30 Oct 2017 08:17:35 +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 65447285CE for ; Mon, 30 Oct 2017 08:17:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A057C899B5; Mon, 30 Oct 2017 08:17:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4352E6E956 for ; Fri, 27 Oct 2017 14:12:18 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id y83so4041507wmc.4 for ; Fri, 27 Oct 2017 07:12:18 -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:in-reply-to:references; bh=MJpTBiatAPleNAbrzbH/UVEgkW8VbIzCfFeGO0WAbNM=; b=ZaBtuVLiAUwZLgxLanTvpnRhigOYzQylreBb4boVifabiwu9o8flCUatoVFfEEeuV4 mJzSaIrmDoUrvOdXdbypF0F8v7hUxovA40qQjSKK0gyYVx+Ar+uL6Phb04z4uN9dS0rq GQrbV1Uy0zNb7Z6VAN3YDv+pjmDQJXFNohkDzi1vsGOgrdw+3spMvUE7GWVZp+SYCc5Q p0qCLzqN2U7t4v9URy07G3MHUFP8Mg1PGTR3MvDJBO3vmfj+HNIvxtrzqjqSme5DQQmI ZdDKVjzn1xZgvXnGSyC8yNGH69n6vjVpQBc8uLmNxlUH1TnJ2dfk+qFQYXQucs/MdK8l pxIg== 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:in-reply-to :references; bh=MJpTBiatAPleNAbrzbH/UVEgkW8VbIzCfFeGO0WAbNM=; b=jwxj46bs3MPWt4YE9+oK73O73PWz43U7EsGi5STi79qFNd41mu6kWnbnKI9c88tMFZ a0/fPQXTR8jMWjjgjQyOaZqej1jmaCiR3iesxkcRRQQlyN4z/N3ica127WzUUlkXd/nk vaMpqtx6deqx4UG5HdWUtjO5CoJRxZxNcBGtL88eSxyZr6iyU05xgcyxedJCxmLu1r5Z A48v74LRuBlE4kGTJocBOa1HfMl7cLQctqkyoJLSaBqy1jHwP6Ym/SK266KSZpTcUnzJ QW/y0uWiaSpWYDTb9Adwu69dJl8HcT1FJNRlVrHKYziABOdsJdGsE+0lJJ8lPj9wiW4C kkNA== X-Gm-Message-State: AMCzsaUT/AU+CC3WGbvBBZ3PVx9yjKnsx/881/C72/V60JzhJ8pxdnDB +hwuzgCLZLlh693Zn8+NOUuntw== X-Google-Smtp-Source: ABhQp+RJEV9LLEd9S1m2FepDUmCtXhJH5EBwT5baaPUjO9wLLapRV96pLCUgyxr3wa9a6Pwk7QAGCA== X-Received: by 10.28.105.76 with SMTP id e73mr584793wmc.116.1509113536857; Fri, 27 Oct 2017 07:12:16 -0700 (PDT) Received: from t460p.intel ([95.146.151.224]) by smtp.gmail.com with ESMTPSA id u57sm7717543wrf.43.2017.10.27.07.12.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Oct 2017 07:12:16 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Subject: [PATCH v2 1/3] drm/i915: Reject unknown syncobj flags Date: Fri, 27 Oct 2017 15:12:09 +0100 Message-Id: <20171027141209.9729-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <150911212437.2864.5413328997342016110@mail.alporthouse.com> References: <150911212437.2864.5413328997342016110@mail.alporthouse.com> X-Mailman-Approved-At: Mon, 30 Oct 2017 08:17:31 +0000 Cc: Tvrtko Ursulin , 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. 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 --- 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..58e994c4b5c7 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(~(__alignof__(void *) - 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; };