Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1641496rwb; Sun, 14 Aug 2022 08:32:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4A/6DN5Ik7YxD2donuNNqxKdTzZsCT7iSoxFsuF8zU4rf6/lRg0Ilnu1dD+Uo3CvtFxxWD X-Received: by 2002:a05:6a00:b87:b0:52f:35bc:f904 with SMTP id g7-20020a056a000b8700b0052f35bcf904mr12577118pfj.74.1660491138177; Sun, 14 Aug 2022 08:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660491138; cv=none; d=google.com; s=arc-20160816; b=SREyaARvICrEIJ9wQ2XCd2jrbL4LJa0mqUAIxKz1JpDaPJHXOjzXk0mG7yjaRWRbqg 8YQF10kl2ysMv73zGpfsyjSHS4CI71+SixiUnjUR3c4m5VI7PFTxefQp/s99a3gjronM YiC/191EXubgfnxbVNPp7GwQ2uWqH47IcqdRuW5UZxP8r2fmQDYbTd4Nk2T6yFA8+wLK x/y2Lg6Yryn3xebOGVlcV+oYHwI+x5CIqRPk7agDhfAd8xK7Grdgskjj765A1ah+rX+G se79E3aCdoV69rUQXbMrhihNmMw0+4ux4gpoS5d6qPQh9e3077S7YmvTH9OYLRz+iAjo Sn2Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VYxXSA9FnblS8mf1O0LjKlbjsL8zZ8af+HaunaRKnRg=; b=V0QFhIU27e7c6GuNnIlpwC4vfQ0nFcedBe+Ru8lQJUb9vQsIOrTk4W4xs/7y5QqMn2 1xDEZS4YJgcxC+sjrz9eT6JQjE/eAEUUvTkHptgdU2y2UeQfiFDzO2pq7yP77jtDi5Gn 4Kp4z8843xWth0+C6q/x7UWLgx1XQ4gacEKhfWmtEyiLyh+ut1KydwO1u4v2o9Nm52pm WiCdoRV1HzE8wbMzeGM2bK/HI9q6SKPft2yO8+qgQl2XdxKo5lnX77H8xaJp+QNYHwfe 5q2NdLtjVHzRclenWMQ5Xl6A234PONLkMiq9Ih712mliYVekOFB8c8HMd36CuxxngVid 6asw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b4Tig7WS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a056a00130300b00534a2afac14si3583923pfu.199.2022.08.14.08.32.07; Sun, 14 Aug 2022 08:32:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b4Tig7WS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240447AbiHNPbH (ORCPT + 99 others); Sun, 14 Aug 2022 11:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240413AbiHNP3d (ORCPT ); Sun, 14 Aug 2022 11:29:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA98F12745; Sun, 14 Aug 2022 08:29:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 13D8060C48; Sun, 14 Aug 2022 15:29:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B54EC43141; Sun, 14 Aug 2022 15:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660490952; bh=epSUldJ7qZaSa/KN4cH2lvf0JxykKV7qMCXgRU+QuaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b4Tig7WSAQWE5KjCd8c/waNY0BkHF03iRvWbS70Ff9GPkgNUII0FeM+76+ICg+e69 EFfcPc71IjVg7Bt7PbDK3zDZq24KrNOO3YYOh1A8vgIPs/EdVoEkNqBSnGoCZJIK7N oFNC5IiE/NNvNTb6Epkj8JkgtY1yHMzcN14r7J7az32H+ISHjnBhTcUVfljedZYx30 LtILdwvu3ltE4SCZmjBMRUsVMuHlHxRYTkuIBDVHMJw0CD0Aco+BYH5Y20J3YVL5m+ 4lBsRvjQ0DT2tlE+Uy7BTHKOELdsX1NSHDDbbvOXRMTn2iAFZsdZvim9+wImCEqUte CZq1ILQ8w8P6g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ofir Bitton , Oded Gabbay , Sasha Levin , gregkh@linuxfoundation.org, osharabi@habana.ai, ttayar@habana.ai, ynudelman@habana.ai, dliberman@habana.ai, fkassabri@habana.ai, dhirschfeld@habana.ai Subject: [PATCH AUTOSEL 5.19 35/64] habanalabs/gaudi: fix shift out of bounds Date: Sun, 14 Aug 2022 11:24:08 -0400 Message-Id: <20220814152437.2374207-35-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814152437.2374207-1-sashal@kernel.org> References: <20220814152437.2374207-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ofir Bitton [ Upstream commit 01622098aeb05a5efbb727199bbc2a4653393255 ] When validating NIC queues, queue offset calculation must be performed only for NIC queues. Signed-off-by: Ofir Bitton Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/gaudi/gaudi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c index e6bfaf55c6b6..3fb221f2e393 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -5654,15 +5654,17 @@ static int gaudi_parse_cb_no_ext_queue(struct hl_device *hdev, { struct asic_fixed_properties *asic_prop = &hdev->asic_prop; struct gaudi_device *gaudi = hdev->asic_specific; - u32 nic_mask_q_id = 1 << (HW_CAP_NIC_SHIFT + - ((parser->hw_queue_id - GAUDI_QUEUE_ID_NIC_0_0) >> 2)); + u32 nic_queue_offset, nic_mask_q_id; if ((parser->hw_queue_id >= GAUDI_QUEUE_ID_NIC_0_0) && - (parser->hw_queue_id <= GAUDI_QUEUE_ID_NIC_9_3) && - (!(gaudi->hw_cap_initialized & nic_mask_q_id))) { - dev_err(hdev->dev, "h/w queue %d is disabled\n", - parser->hw_queue_id); - return -EINVAL; + (parser->hw_queue_id <= GAUDI_QUEUE_ID_NIC_9_3)) { + nic_queue_offset = parser->hw_queue_id - GAUDI_QUEUE_ID_NIC_0_0; + nic_mask_q_id = 1 << (HW_CAP_NIC_SHIFT + (nic_queue_offset >> 2)); + + if (!(gaudi->hw_cap_initialized & nic_mask_q_id)) { + dev_err(hdev->dev, "h/w queue %d is disabled\n", parser->hw_queue_id); + return -EINVAL; + } } /* For internal queue jobs just check if CB address is valid */ -- 2.35.1