From patchwork Sat Nov 23 19:53:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11259953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3435138C for ; Mon, 25 Nov 2019 08:07:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC59C207FD for ; Mon, 25 Nov 2019 08:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC59C207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F0DD895B4; Mon, 25 Nov 2019 08:07:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFE946E037; Sat, 23 Nov 2019 19:54:38 +0000 (UTC) Received: by mail-ot1-x344.google.com with SMTP id 66so3067401otd.9; Sat, 23 Nov 2019 11:54:38 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=eBi2Kl2b0LYogSQpnyXzwnLfzkWlslGs6DkAiJ/ff28=; b=UYKD8snLCJ+4+8i4h0oDQddFFAb0D8JzG9L5PRSTt9wQ9v/PV3LPTHAL5p5HkaG7o3 RHRVyYgdPTHJdFecrDsLPjg42O45mfK+ebyqjH8B2rNfbnVE1FbzBj1UFQIq0fKhS3ee 2kiEKCTQgqA0YuAOf4QDipaQkAJWrJ8hquoA2C1j9t+aFjCg+jhTHPCHbqK9osuDZUEY 20pEmDJXv5FtRZOPHtkWmYggvyg38O1aV77XwFEeNQ1vCVNELMun8Mze+ktcZMtt62Bw 1BJ/OJs5TncvXCjhhxlA4Gyt9eInN6GtGtsC6TYltYUp2FTiPlUvv8+mM2v9QY0XYdda dkoA== X-Gm-Message-State: APjAAAUcp8/DiRsanlhil7t7V30NOyYzgyDNgaHOQzNUSDJMHqsW6QiM ZKEZyvpCgVVzdUX35akFf98= X-Google-Smtp-Source: APXvYqw6JW+8ls79ZOkf2SzoYXqnRhAFKkJsw0ixPFreStxhWdjEhfjD+sVK9MQap+7EvdpLTrZknw== X-Received: by 2002:a9d:734a:: with SMTP id l10mr15424321otk.339.1574538877966; Sat, 23 Nov 2019 11:54:37 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::7]) by smtp.gmail.com with ESMTPSA id t11sm577254otq.18.2019.11.23.11.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Nov 2019 11:54:37 -0800 (PST) From: Nathan Chancellor To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi Subject: [PATCH] drm/i915: Remove tautological compare in eb_relocate_vma Date: Sat, 23 Nov 2019 12:53:22 -0700 Message-Id: <20191123195321.41305-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-Patchwork-Bot: notify X-Mailman-Approved-At: Mon, 25 Nov 2019 08:07:41 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eBi2Kl2b0LYogSQpnyXzwnLfzkWlslGs6DkAiJ/ff28=; b=YkJYM5C8pZQpOQTmbHQItGF438cTOP0Wxu7XuZE3iJCWH1utSuXHYIOmS9Mmxb+jCL A97dXlwNujP20TqqWJX3sz83Odhrwmlk3d6CJqRsxeOHc9Uem6OindxVvquqeghrmK4o KhwfPCQtEiVpkOfZuIyMmrnb7bTyAEUl6njOmQPqFR6WHZHKWXjNIn+qxnD5ay7hKzik Cz70Qse3hfob47U+wEpuz0mwv2O8NBZ1kDum2bB/wuwTYl+TM+18eVsp8DPIw/LWgdeA JFGZfmyjoBPUYfbHirI46Dkf3B4FhvxEB/nz28sKKkAr/t78q/x+L0mj6Gk3j3CNroEj EISg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, clang-built-linux@googlegroups.com, Nathan Chancellor Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" -Wtautological-compare was recently added to -Wall in LLVM, which exposed an if statement in i915 that is always false: ../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning: result of comparison of constant 576460752303423487 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare] if (unlikely(remain > N_RELOC(ULONG_MAX))) ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ Since remain is an unsigned int, it can never be larger than UINT_MAX, which is less than ULONG_MAX / sizeof(struct drm_i915_gem_relocation_entry). Remove this statement to fix the warning. Fixes: 2889caa92321 ("drm/i915: Eliminate lots of iterations over the execobjects array") Link: https://github.com/ClangBuiltLinux/linux/issues/778 Link: https://github.com/llvm/llvm-project/commit/9740f9f0b6e5d7d5104027aee7edc9c5202dd052 Signed-off-by: Nathan Chancellor --- NOTE: Another possible fix for this is to change ULONG_MAX to UINT_MAX but I am not sure that is what was intended by this check. I'm happy to respin if that is the case. drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index f0998f1225af..9ed4379b4bc8 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -1482,8 +1482,6 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma) urelocs = u64_to_user_ptr(entry->relocs_ptr); remain = entry->relocation_count; - if (unlikely(remain > N_RELOC(ULONG_MAX))) - return -EINVAL; /* * We must check that the entire relocation array is safe