Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp298450pxx; Wed, 28 Oct 2020 05:19:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVLqmXNZuYX3aNdHXu5XiUBwGvdOvoxGKdxblV6DNMzDwXZTBy8BP+pb4khnNlV4esfHiW X-Received: by 2002:a05:6402:32f:: with SMTP id q15mr7393417edw.230.1603887562533; Wed, 28 Oct 2020 05:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887562; cv=none; d=google.com; s=arc-20160816; b=foMzTmImsy6ombdBSYDnVdYRb1D5NtBu23naomjjLNUOyA3yeZJWZuLuKaEsnXqDE8 7qZ4+ZL4fMUgkd2UmbT9OjSAECyeWVAmXIy7rY5R6NmE2fuwDSlzIX3eHbEXbAe9Abt6 xu7oPL5u1m8GexiWR4s+TY7TM+oNMIQ5l5usja/m5nl00Vs9FsxA4CWhpGANicg5A70r YFsyG/beOUCo80BXRgHNNTcQoyx6PGcRTn9vRZg+vDfNkAfyY0X+OoO5eka+kG5jElaq nqNKOj30LQCSmbVVqqDKtr48Ur//Rj9hPZDzw+KbjLx9nN8UuHTg6ywyyabkCueQ/1cF wO6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OR3j+m/czu1RD7VTSX23qvfwzGAJOxxioG8M8bF8oo8=; b=ZuuBgvSdRK5ZjCLtcF/QTGO+bBPbn8LOsPS7rjEJnioDPmvQSwk2I8s5BzzKHZ5aZ4 gqaKniUs1Eqzlmfi5o+3YPonk9W2NUW0d02vHPEGp4Y2b7fbWuahnHiEmfy6GE2m1b47 BDjEMBIEmoxo21FmAx3Ubxfv27VRAheEoCZK3Swh4uNMhL03Lggjr9hGJqAuwmsV4l8Q udr7TV39dWg4GP6yXd82Y4ZQYSO5R7qzINeIQFtsAjpOGVu+6H+wmYPeVKg9P2rMYn8e CLyYL59PKaKL6tLU/DFZY3gB9d4kP7w3VA6scbR4cAwVtqqIZe41C+5wOcAxKQ3anwEJ SPrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EwzDnR+i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si2868715ejb.712.2020.10.28.05.18.59; Wed, 28 Oct 2020 05:19:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EwzDnR+i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1796498AbgJ0PTD (ORCPT + 99 others); Tue, 27 Oct 2020 11:19:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:51720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794969AbgJ0POk (ORCPT ); Tue, 27 Oct 2020 11:14:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85D5820657; Tue, 27 Oct 2020 15:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811679; bh=vTaxP/Ekyc5Pa8UyF7ePf+/WcBxBH/HKiBPLA17whKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EwzDnR+iJJgNtKuff3sIY2JVbQGPVJjj6AJh1uNS89pNYXKlWUhwMCxAtdEe7Riq3 sZc/m6TdO0gp1nCLKXVTWtAztVYPDoeryx5KSlv9s3CfEiXFzR6IYMXiJIX7t6rDQs kBn77FzKdmIR9cDdf/DHHZ0mcmfD5PUPFtNrdPmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dan Carpenter , Oded Gabbay , Sasha Levin Subject: [PATCH 5.8 577/633] habanalabs: cast to u64 before shift > 31 bits Date: Tue, 27 Oct 2020 14:55:20 +0100 Message-Id: <20201027135549.878325296@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oded Gabbay [ Upstream commit f763946aefe67b3ea58696b75a930ba1ed886a83 ] When shifting a boolean variable by more than 31 bits and putting the result into a u64 variable, we need to cast the boolean into unsigned 64 bits to prevent possible overflow. Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/gaudi/gaudi.c | 8 +++++--- drivers/misc/habanalabs/goya/goya.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c index ca183733847b6..bcc45bf7af2c8 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -6285,7 +6285,7 @@ static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask, is_idle &= is_eng_idle; if (mask) - *mask |= !is_eng_idle << + *mask |= ((u64) !is_eng_idle) << (GAUDI_ENGINE_ID_DMA_0 + dma_id); if (s) seq_printf(s, fmt, dma_id, @@ -6308,7 +6308,8 @@ static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask, is_idle &= is_eng_idle; if (mask) - *mask |= !is_eng_idle << (GAUDI_ENGINE_ID_TPC_0 + i); + *mask |= ((u64) !is_eng_idle) << + (GAUDI_ENGINE_ID_TPC_0 + i); if (s) seq_printf(s, fmt, i, is_eng_idle ? "Y" : "N", @@ -6336,7 +6337,8 @@ static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask, is_idle &= is_eng_idle; if (mask) - *mask |= !is_eng_idle << (GAUDI_ENGINE_ID_MME_0 + i); + *mask |= ((u64) !is_eng_idle) << + (GAUDI_ENGINE_ID_MME_0 + i); if (s) { if (!is_slave) seq_printf(s, fmt, i, diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index c179085ced7b8..a8041a39fae31 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -5098,7 +5098,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask, is_idle &= is_eng_idle; if (mask) - *mask |= !is_eng_idle << (GOYA_ENGINE_ID_DMA_0 + i); + *mask |= ((u64) !is_eng_idle) << + (GOYA_ENGINE_ID_DMA_0 + i); if (s) seq_printf(s, dma_fmt, i, is_eng_idle ? "Y" : "N", qm_glbl_sts0, dma_core_sts0); @@ -5121,7 +5122,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask, is_idle &= is_eng_idle; if (mask) - *mask |= !is_eng_idle << (GOYA_ENGINE_ID_TPC_0 + i); + *mask |= ((u64) !is_eng_idle) << + (GOYA_ENGINE_ID_TPC_0 + i); if (s) seq_printf(s, fmt, i, is_eng_idle ? "Y" : "N", qm_glbl_sts0, cmdq_glbl_sts0, tpc_cfg_sts); @@ -5141,7 +5143,7 @@ static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask, is_idle &= is_eng_idle; if (mask) - *mask |= !is_eng_idle << GOYA_ENGINE_ID_MME_0; + *mask |= ((u64) !is_eng_idle) << GOYA_ENGINE_ID_MME_0; if (s) { seq_printf(s, fmt, 0, is_eng_idle ? "Y" : "N", qm_glbl_sts0, cmdq_glbl_sts0, mme_arch_sts); -- 2.25.1