From patchwork Tue Jul 9 20:23:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13728473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7D5FC3DA42 for ; Tue, 9 Jul 2024 20:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UuCZ+qtZuHwlK6whSWPf8p+h6hNNgJzBMctNbfek56A=; b=NeAkOZusyGVBckpEsddiUTYe5+ Ux/87JJd6ATG0Kc7zscLOx8gh9bE+D9gk9KjWPpu4Yte+2DSAC+jWUSsjpRBdDqhGjr5J0u+LS6NS sDwhSwmO4kJzgWvgS7GA31yO3K3kmjOkxcGmLiTVtLwW6TJJmjPShg3Bv+1Yix/jPogxrJzHTTE9u bIHCWL1VK/AcRmFPsC1afQY1DZ+TI81r2lVynPqhMZ4v94phknufJNbaqhXoVBedb/AT0dvI3lDH3 iKYVL2/YAa3MTnVDGLim/VRmXVf5OxWMNJ1av5xb0iuWB9LpBD5LvBqsunU0YSMXuPST146umtxcq 8no0gKXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRHOC-00000008Vor-2Dor; Tue, 09 Jul 2024 20:24:40 +0000 Received: from mail-dbaeur03on20600.outbound.protection.outlook.com ([2a01:111:f403:260d::600] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRHNJ-00000008VMK-1Mqb for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 20:23:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CRfFcRjES5+NCMe2aNsL1z+KPE9k2BsDOo+1VbA8xLDSeB4yoIeboO971wkmvt8b+fm/zHMvy6I+wmJtBOnQ2Q6TJ1S0CH7QCOwxkJCqlEDx+rfziPJPAh0/LcLeJY9DWyymYZ2Hn/mRpjg1uENxP3tqvx0zciU10itsEQcnPxOgGDF0jFK1v/EvSLRUDvDiSE9HsE+IdC+z/8+iN7VerKY+NMrK4Y6ZwYuIWlfSD31HUc5SVvLwFVmqD2FbZ/xe/XX0vQ0zMXM4o//amfLJgXtaPIZOXmO1OSVWi9YXxSjkS0Rhib9lS41B+el0saPZuU1ia5PwfaunOGU2JmbZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UuCZ+qtZuHwlK6whSWPf8p+h6hNNgJzBMctNbfek56A=; b=LpGL42Q2woBPdiAx8Jh54mvgJ8NjCWS8Mxw1HQu2T8fWnkAfdkTlyzj6DJW4omyjBWUA7fco9q7+Lfk0aXseiobvNE8gLKgVJxn1VYjYqzR+ZlrwfFmjBSTiDZBG/bZaf4Kx3T1KwgIkpraEtFy1yH8bN8krnHHCdUV18TL79TDEIxdnX+NgSmXijyBqtxgIZIo6guCzzK5MIVeHzI/BnFeOx/VICX+Mbp0sIfsBqj3fruy5asedfqLSNN8VKVRl0WlBZiIJY6hOs5JgnvYUIWzYnv3trMV+Q3oHR8yjuMnpc/xpMiULNqmL9E/4K2PMgYfJJXRhuFNcmQrpwVLvcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UuCZ+qtZuHwlK6whSWPf8p+h6hNNgJzBMctNbfek56A=; b=GxngbnE2yRRyl0jdZZGSxkcGHuGqLUtKte4r5PoDh6MLXhTPjW6xoJWxOsjxi9vIGfeufJcXNjGVtR606JQr/Cqidq7EksP9JV/JmCoixq3Np+f1PTFzjuV/80Xrmu3T1nwtZ7xcSTmsVmA/KOGHmZ24GP1f8KAQpe/8S6PTVkA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DB9PR04MB8267.eurprd04.prod.outlook.com (2603:10a6:10:24b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Tue, 9 Jul 2024 20:23:42 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7741.033; Tue, 9 Jul 2024 20:23:42 +0000 From: Frank Li Date: Tue, 09 Jul 2024 16:23:04 -0400 Subject: [PATCH 3/6] EDAC: fsl: Fix bad bit shift operations Message-Id: <20240709-imx95_edac-v1-3-3e9c146c1b01@nxp.com> References: <20240709-imx95_edac-v1-0-3e9c146c1b01@nxp.com> In-Reply-To: <20240709-imx95_edac-v1-0-3e9c146c1b01@nxp.com> To: York Sun , Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , Krzysztof Kozlowski , Rob Herring , Conor Dooley , Krzysztof Kozlowski , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Frank Li , Priyanka Singh , Sherry Sun , Li Yang X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1720556601; l=1758; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=yIBDEMa1tOArl3nH5oE1mzsXvIC+50RpgJfJD2pCSww=; b=puMEO4pwlHPQzAg1IqC+fRj92Cu/EFmnqVMekfg3xaM+mcKdL7bovGBGfwQZKOWQSEJjcHrgM c9UPnlILtDwDBxTuLn+efAGFo38VutXUjDvmdyv8jCf6ck8PKxMiVPz X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR03CA0033.namprd03.prod.outlook.com (2603:10b6:a02:a8::46) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DB9PR04MB8267:EE_ X-MS-Office365-Filtering-Correlation-Id: f71cb98d-c8ac-48ad-6511-08dca05506bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FPcbrqnQSD0XbOjlAKL6VOsaXnrVt/3?= =?utf-8?q?ibsetWhMdlw4LJaQqOdYliq08mRf/pT5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Q8QMVcLsVQgq7PYj7osOhSr+BZ?= =?utf-8?q?OA5EgM77AjqPhu/tGkWMuFrXf14tsMQwCwB9McDpfDaQgb7Sxt3QaR47skYuHV22w?= =?utf-8?q?tTM4FFBkyy8clN2OxDvLrqne4hra285La6bsc39zCn/RZLhUQl9ROgs67XImcLPJM?= =?utf-8?q?TeOIRJD6DZhMRt87O3JTon18UG3aaUhKHNnBqSnZ4bY9wCpMVrXug3sSFXlbAkPdX?= =?utf-8?q?WTUor0mwBxbUywb1bT/EJ9O2unk2ShwRZ29efOlGFwolRdx0scn2UB2tpn2O07usv?= =?utf-8?q?W858LEvdzHcq2kx2W1UmjXtcvIrxrtyiSTMt4mbvmVms7VCeF9Ls2aRLqis3Cz+7T?= =?utf-8?q?h09Cm+AXnpzxTjRXEW2vSjGJk/1tPejXV8uomdRdyR1uxaZCa0WEgyQinRqc4GZGR?= =?utf-8?q?i3npQWA84fZRMCBL2LIVtN42ZaVfHEKGSV+i3ZM+B/oNY2oDkBgtCcE=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?nTcSzyV4MXSQmwZJm4Ym7WAaYASj?= =?utf-8?q?061agWLlpXRy0q0wFuhHkfbKK7Cw66A/CjnfKsiHm2VHfOYb51uauFLIJ64u1e7Ai?= =?utf-8?q?tRqG3qZtFQ2bW/kQzo8CN+ofdsQiAPxbmGZ5VUgLjKOTFdFh1BiVJiF34R90N/fB7?= =?utf-8?q?4t5aeY9dsjl+rkvmNsF4fIO+INywszDupz0Ya2ltYcZLlstxuuF0nh4aWBVihHonu?= =?utf-8?q?DoQBO96j9QOX8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pYwh9mJ+6g5QsNSHb4pkymQtGm5O2QCB/b/LIRjlftGym?= =?utf-8?q?L9WQ1fNAwDPcwuN3LO4jq8aYl6o1BR/Gqe1Y0ENW1HUWJizNOdpCPQhoRj7Z+famq?= =?utf-8?q?jbatDqfNwdjzHey1qgH0OjtKces7M9UCFBuqW61RfxglYnX/hYg858JW/8qP4wfA4?= =?utf-8?q?fHcnZ/q2jtLQD1C1IX5Dk6Jk9CcvA2k588kshL30yoOyWVBahW+kur4f0KdXg5ksB?= =?utf-8?q?VyqCnT2h9JCGtUFd8EEF6kmOHDrtwwAMeqxZHW5RVHJgodfCwSl03KLeDc865WtXh?= =?utf-8?q?0J2+yhBmxJx7mXGplHlHoxIK+JMhkdBKUNg9Nce1bJRejJfiVX6RFN3zrsODTrvWW?= =?utf-8?q?Z0cPr9iLQHa37NT91+NhlazeLdKMU+lJQl+FmrTTfObeobMHn92SeNHkdMmQQ3AeO?= =?utf-8?q?2Dh/FfjlsxUv?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f71cb98d-c8ac-48ad-6511-08dca05506bb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2024 20:23:42.6521 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XstainIzzxSB29QtlC7RI/USSLnwdc7EIL3+j9luyi7GaoP6YxGWrHQN76kEE4f4KYSEAkc5NjO+KbyThfUW/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8267 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_132345_469990_8970C489 X-CRM114-Status: GOOD ( 11.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Priyanka Singh The original code: cap_high ^ (1 << (bad_data_bit - 32)) The variable bad_data_bit ranges from 0 to 63. If bad_data_bit is below 32, bad_data_bit - 32 will be a negative value. Left shifting a negative value in C is undefined behavior. Fix this by checking the range of bad_data_bit. Fixes: ea2eb9a8b620 ("EDAC, fsl-ddr: Separate FSL DDR driver from MPC85xx") Signed-off-by: Priyanka Singh Reviewed-by: Sherry Sun Signed-off-by: Li Yang Signed-off-by: Frank Li --- drivers/edac/fsl_ddr_edac.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/edac/fsl_ddr_edac.c b/drivers/edac/fsl_ddr_edac.c index 10b0a46669f3d..da743cf8a95e9 100644 --- a/drivers/edac/fsl_ddr_edac.c +++ b/drivers/edac/fsl_ddr_edac.c @@ -338,11 +338,18 @@ static void fsl_mc_check(struct mem_ctl_info *mci) fsl_mc_printk(mci, KERN_ERR, "Faulty ECC bit: %d\n", bad_ecc_bit); - fsl_mc_printk(mci, KERN_ERR, - "Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n", - cap_high ^ (1 << (bad_data_bit - 32)), - cap_low ^ (1 << bad_data_bit), - syndrome ^ (1 << bad_ecc_bit)); + if ((bad_data_bit > 0 && bad_data_bit < 32) && bad_ecc_bit > 0) { + fsl_mc_printk(mci, KERN_ERR, + "Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n", + cap_high, cap_low ^ (1 << bad_data_bit), + syndrome ^ (1 << bad_ecc_bit)); + } + if (bad_data_bit >= 32 && bad_ecc_bit > 0) { + fsl_mc_printk(mci, KERN_ERR, + "Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n", + cap_high ^ (1 << (bad_data_bit - 32)), + cap_low, syndrome ^ (1 << bad_ecc_bit)); + } } fsl_mc_printk(mci, KERN_ERR,