From patchwork Fri Apr 7 12:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Krishna Gajula X-Patchwork-Id: 80770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp250050vqo; Fri, 7 Apr 2023 05:29:50 -0700 (PDT) X-Google-Smtp-Source: AKy350bk+k/3rvBJZmAOQtSdNpz/nKLjsvMrX9+gyJT88Q7Gu0zNPFtDv+sO8q45kkodDxFe+D3H X-Received: by 2002:a05:6a20:6626:b0:d8:e90b:78 with SMTP id n38-20020a056a20662600b000d8e90b0078mr2302485pzh.45.1680870590529; Fri, 07 Apr 2023 05:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680870590; cv=none; d=google.com; s=arc-20160816; b=lzAYzmY5HLZSZO9iPxxy+b2K3437W3gLG7yetj/2UmDq2SHrvlOaiQTx0FQ9oykWOU gtnPBaItvF2nBumCpYOgrBnrZMSTOtF3T6RL5S/ugN53JmmFufOQ6FK73Jk31wCYUpYi L+BYBJTBSFyxK4RpftaMc/WXKDubgU3V/siwXDpnF69ptw7rlMkBbRrrcWjTrkUWMGdN ST1kHfu8SQPnZlNiWrRXJAtM6UwMRng1sa7DulXfnbpaxHgREvH4K9X5eQ+O/h2QgO9m /4ppCZ9TSi91tmZpww7rRCCHqdUe7fqfEf32TnzT570Z0jCCtvu8HIk/JwiIw2NoVjga /yJA== 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=/1EraJ/KOS82xadi014qOEu9vIJ5vyi/xvCLp1ys0n4=; b=ZVGl+SW+8NcgiQbsEoDZge3HJtVF1LK4E4weP1Hcrd43PHuL37dgpUu7xaNeTiGVat 3O2i6DWAIgk6rIBXCO7c+o1EldYKd7lGyXYxbCM00yY9mIMAIP/QQsoDBusF8ZOn1ikx gsQc7siea2MDaahZdDF5zngD8/YP0lI5SNr9IfZ3srxxhmzRQPi05jKJfVA6HmEX5Bya tvJyWrHEvt5PV5N3NOt1LUuwrUYcP7bCGXCiZnM6p/NLSVVgz9DYPJtHeqQVFuQsjLDX dl6Hwz1h2Jpy2VU9lHgEgZuRx7QJqECDeW/Yguu3jm163muWxobcRil1p/oyEjMZyK6A VHCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=i2dL+p+a; 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=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 64-20020a630443000000b00502e76a516csi3578207pge.500.2023.04.07.05.29.38; Fri, 07 Apr 2023 05:29:50 -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=@marvell.com header.s=pfpt0220 header.b=i2dL+p+a; 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=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240753AbjDGMYX (ORCPT + 99 others); Fri, 7 Apr 2023 08:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240723AbjDGMYP (ORCPT ); Fri, 7 Apr 2023 08:24:15 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84039AD32; Fri, 7 Apr 2023 05:24:14 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 337AwmMb000622; Fri, 7 Apr 2023 05:24:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=/1EraJ/KOS82xadi014qOEu9vIJ5vyi/xvCLp1ys0n4=; b=i2dL+p+a2hwY9hD+mvMmueS4VLsVB9+VF4V9Wq7WYvuYaBONPQfMBpfoQjEsKo+RuFfQ 4HPXtCuHSjGikhZ5hiydmN0AkYugBJc2ZAcQZaF3D5oL1zdfbbn0QGlNdTunONXlhK5p lnIV8cnu9QaEIpWuCgyb2HAZNAp7EspNwCXf2cURzCuZW7xSHZVndVcvLVfH6paQlWgD s5n9qS0lGOTs1FSJPLnMKRt/eIXCSKiw5fCeuO4WOq3AubqmpJvCirkFEAHty8XhbDJZ /iZScuRdZW9aTeWtg0MDLc6inT97/nsNoImEPZjjAjfkQF2r1ZQmeo3YmGaFKoAf5mNa Dg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pthvw88q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 05:24:08 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 7 Apr 2023 05:24:07 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Fri, 7 Apr 2023 05:24:06 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id C2EE33F7064; Fri, 7 Apr 2023 05:24:02 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v2 3/7] octeontx2-af: Add validation for lmac type Date: Fri, 7 Apr 2023 17:53:40 +0530 Message-ID: <20230407122344.4059-4-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230407122344.4059-1-saikrishnag@marvell.com> References: <20230407122344.4059-1-saikrishnag@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ZFoNIYd5WKTaD56V4R7BOvRRoLKsCAxj X-Proofpoint-GUID: ZFoNIYd5WKTaD56V4R7BOvRRoLKsCAxj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-07_08,2023-04-06_03,2023-02-09_01 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762520560696758126?= X-GMAIL-MSGID: =?utf-8?q?1762520560696758126?= From: Hariprasad Kelam Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware. In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field. Internal error: Oops: 96000005 [#1] PREEMPT SMP [ 35.321595] Modules linked in: [ 35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted 5.4.210-g2e3169d8e1bc-dirty #17 [ 35.337014] Hardware name: Marvell CN103XX board (DT) [ 35.344297] Workqueue: events work_for_cpu_fn [ 35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO) [ 35.360267] pc : strncpy+0x10/0x30 [ 35.366595] lr : cgx_link_change_handler+0x90/0x180 Fixes: 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to PFs") Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: Sai Krishna drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++ 1 file changed, 8 insertions(+) Reviewed-by: Simon Horman diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c index 724df6398bbe..bd77152bb8d7 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -1231,6 +1231,14 @@ static inline void link_status_user_format(u64 lstat, linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat); linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat); linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, lstat); + + if (linfo->lmac_type_id >= LMAC_MODE_MAX) { + dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d reported by firmware on cgx port%d:%d", + linfo->lmac_type_id, cgx->cgx_id, lmac_id); + strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN - 1); + return; + } + lmac_string = cgx_lmactype_string[linfo->lmac_type_id]; strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1); }