From patchwork Tue Jun 28 02:41:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Wang X-Patchwork-Id: 586204 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2053C433EF for ; Tue, 28 Jun 2022 02:47:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244850AbiF1Cr1 (ORCPT ); Mon, 27 Jun 2022 22:47:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343784AbiF1Cq7 (ORCPT ); Mon, 27 Jun 2022 22:46:59 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4637227CE9; Mon, 27 Jun 2022 19:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eA+KcigLfVXdQYrcg/GZj+Xeaic5psOj0mkoI6Dqd8Rl741PYFVXmm5zO/TtHt+vIt/G6ERcbumH8hNZXBsXl95bMfN4Aexrgudj1BzkAG2+0ciPGxOHkPrI5xjRjXQdSteTUoS0BSFsc2WvrfHb6T6O/zBFbFqKXykjD/BiKydr7mwmOLRqrkotScprYUeEMKHhxessgVp9bgGHsJSoA6n0ge5VqXZSk5I7Yo7fSoz2wVfx5CxbvWp0re6CX7kf+GuxTxHdT/VKEtr05O8GBqiNSEBjo0cQZGGQv8JV5tKf1BPYqu5q5vS6rREEbulhCAtv34SE5cZs55WKng8QPg== 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=etxzazSc954sWPRVXqa/8rCjRcMUNzBN+7wbumjRfHQ=; b=Dw18Aidqgo1t/TTsdEceuDJnUgzf8JT5Au4L2IdDDstMth7OI+Fzki9h2zyS/4k52g0hC1GK6Pj9SXZuny6AlAaUB5suH6KNDhN0BN+omnItgkGSt7mzpH2QH3/kiB9W9cttN1qfHclKoeEJPy/9b9+6BOsqBdAeryBpJFEHpLxS0yedOnyMa2co4QY+1ew47ezGy9TGN5LDmylzcr7Nq/ZhwQH+IcvE84N37xpXUF9pqYjz1RvYBlvMSuqgZQVFVOngkCkKTGQuq6ZQ7nhFydgpGUE2HfAIWYXLvUhCgXLPd92BO1+zYzBL4nDomivSYMcq0oAwg+pSBTRlrRiqkw== 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=etxzazSc954sWPRVXqa/8rCjRcMUNzBN+7wbumjRfHQ=; b=SSG3tjJnatZLaLTrPdMN87af+zPIdAhaPL/3/YxRrUefSwC9kWRPdWl5WwlFq6+WGpyBz/nJk6qUOwPm5/xHiZILZLJI0o6/bfCML/H2+L6su/AmpCHeShm/O9CctBzcQ5K2q5kqnD57s7F+Ff5Rsx4b9TlsQjVXPjN0CxDXL0Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8304.eurprd04.prod.outlook.com (2603:10a6:102:1bc::10) by AM0PR04MB6963.eurprd04.prod.outlook.com (2603:10a6:208:18b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.21; Tue, 28 Jun 2022 02:42:15 +0000 Received: from PAXPR04MB8304.eurprd04.prod.outlook.com ([fe80::6c24:a20:26bd:60df]) by PAXPR04MB8304.eurprd04.prod.outlook.com ([fe80::6c24:a20:26bd:60df%3]) with mapi id 15.20.5373.018; Tue, 28 Jun 2022 02:42:15 +0000 From: Zhipeng Wang To: wsa@kernel.org Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: core: Disable i2c_generic_scl_recovery callback checks with CFI Date: Tue, 28 Jun 2022 10:41:55 +0800 Message-Id: <20220628024155.2135990-1-zhipeng.wang_1@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SG2PR03CA0132.apcprd03.prod.outlook.com (2603:1096:4:91::36) To PAXPR04MB8304.eurprd04.prod.outlook.com (2603:10a6:102:1bc::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5141d08f-b66a-4765-320d-08da58afcf50 X-MS-TrafficTypeDiagnostic: AM0PR04MB6963:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bxzBhuo5HgV5bewMDSAgnWLgpeelrc7bHYgz1PsjU7cKnU+YDuylPWp3E3FAO545A/4dhzn3T20LG36WgnP9PemhiuozEnZoJR1/T8VZP/lYjLquAIrc3e6SHkOMo3zZGtUf9y6a4UsjkQfhJ6bVDUJ5Wf426dviTf/wzMxmzrV3MWfqfuldWXzzMS0yvfwKO4jQ5Jz5UfbD6aMQO02mawroZxyrknTXdm8/zmj0EbYeksfoEjkZSnAaQ7s6cTQQ6hSM/sDZMNrwqFsxrEPuW1knONfUqKgHx8mpoX17SGShXws2EVjy4cEkZrlHbvHRMEkfwD9zjYr89xGhM7vE5+5IfAUyywpldZMQ3u4H0UTEgPrOZpPgPSDS4dUqVZcHgIu155ujYfDXKuYIH7gQzmhSqiu4OkDR+WMlqdOsqH1r/D34Y291BI7cRCSDlGD1LqG89pNq3ZyAEzN71g80yUoNVz+ghHSZso869K905eKHeoNkxW6F3QmWuaYRjpd2K5H6/zNAr74jpCLQLB7U2aSnXCiq3r/3sa7LOmURgCuK5yLx9x1hwVQKINFZbxSMCTe32yUPMfY1g4P3HG0u2Q5fp+EIkeBv1a3bHZfT+YkGkj/0T6FqGpZw3s2rK1BeFfiEHss70quCP/vXhGvSR65xNpXVrjH5jdGja3xfjewgS3CImwM9NY9hIazgrT6EC89m+VdSHxchkf84IWo/HjYQLmaEDwID1EUZi0+OinSIKBJldq0arVotU7a8HccbUW5EhMhf6qOFSYN9BO6Pr4TPi3NAmGibjwFotJJMcb7i6E3gXn95oJYjsWf7xvP5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8304.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(66476007)(8676002)(4326008)(66556008)(66946007)(6486002)(478600001)(2616005)(1076003)(6512007)(26005)(316002)(8936002)(5660300002)(6666004)(41300700001)(86362001)(2906002)(6506007)(6916009)(83380400001)(186003)(52116002)(38100700002)(38350700002)(36756003)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AL+wcdk4aJjXVLMKomHbE7c/zNYb3ugmicnDlFPeMbPnyh74mFjOWZo5FMovwvfpQOewxaZ81D/cV70e9wL/v/mhhQInut6UBB+4wIiup2knPSz5SOQqI85yRhWuShwAqQnO8BvBhG+xKSjcVZJOriQKu+y832HHHc1a8wJAmOOH1NFa1npxRPqjxqBUJhrR3FXk8iHEXqhcBpOn3ZiNL+KubE9SNzcZ1NOLiwjhznP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6IKHXxA8feCuv+bo6VUK0MRPTV22N5vZgh9H70GuIeVbk1zKFTUJN+CL2lfBch8vgLsoQczNsjimDAXB/TJklxt2CEI5JC7BryefNawFLUvrCNRDWIrxWBwkvKD0Tlg0NK/a1yT5eo2bls4pD3WPeDHJA2tDd3RNkEBWb2ALrFfYa0RQc5PYIfzeTYpxEl9BVJWuHpE4AHhfik7Tc4bHgHCQ8XqKG96SYI46CYL6K2RX0Hn+seW3F/Miahxa/JAM7kSFRmmiC+rBo8QEhCUM20/wsTMjGYkTeCyYVRKTFnoldEMw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5141d08f-b66a-4765-320d-08da58afcf50 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8304.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 02:42:14.9818 (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: wpHGvmOu1onbG5yJFXuudSphI008MsVQ6b2xos9kpVIJh9w2WuMs8zonYlUMj6f+qtQ0sCcnaerBT4bVmXiGyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6963 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org CONFIG_CFI_CLANG breaks cross-module function address equality, which breaks i2c_generic_scl_recovery as it compares a locally taken function address to a one passed from a different module. Remove these sanity checks for now. Trigger I2C recovery through SCL connection LOW. [ 2.452853] Kernel panic - not syncing: CFI failure (target: 0x0) [ 2.476964] Call trace: [ 2.480104] dump_backtrace.cfi_jt+0x0/0x8 [ 2.484909] dump_stack_lvl+0x80/0xb8 [ 2.489273] panic+0x180/0x444 [ 2.489282] find_check_fn+0x0/0x218 [ 2.500079] i2c_generic_scl_recovery+0x390/0x400 [ 2.509573] i2c_recover_bus+0x3c/0x84 [ 2.509582] i2c_imx_xfer_common+0x60/0xd50 [i2c_imx] [ 2.521005] i2c_imx_xfer+0x1ac/0x3ec [i2c_imx] [ 2.531196] __i2c_transfer+0x2b8/0x910 [ 2.531208] i2c_transfer+0xd8/0x1cc [ 2.531216] regmap_i2c_write+0x54/0xa4 Signed-off-by: Zhipeng Wang --- drivers/i2c/i2c-core-base.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index d43db2c3876e..87bca6d8514b 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -334,7 +334,8 @@ static int i2c_gpio_init_generic_recovery(struct i2c_adapter *adap) * don't touch the recovery information if the driver is not using * generic SCL recovery */ - if (bri->recover_bus && bri->recover_bus != i2c_generic_scl_recovery) + if (bri->recover_bus && bri->recover_bus != i2c_generic_scl_recovery && + !(IS_ENABLED(CONFIG_CFI_CLANG) && IS_ENABLED(CONFIG_MODULES))) return 0; /* @@ -415,7 +416,8 @@ static int i2c_init_recovery(struct i2c_adapter *adap) goto err; } - if (bri->scl_gpiod && bri->recover_bus == i2c_generic_scl_recovery) { + if (bri->scl_gpiod && (bri->recover_bus == i2c_generic_scl_recovery || + (IS_ENABLED(CONFIG_CFI_CLANG) && IS_ENABLED(CONFIG_MODULES)))) { bri->get_scl = get_scl_gpio_value; bri->set_scl = set_scl_gpio_value; if (bri->sda_gpiod) { @@ -424,7 +426,8 @@ static int i2c_init_recovery(struct i2c_adapter *adap) if (gpiod_get_direction(bri->sda_gpiod) == 0) bri->set_sda = set_sda_gpio_value; } - } else if (bri->recover_bus == i2c_generic_scl_recovery) { + } else if (bri->recover_bus == i2c_generic_scl_recovery || + (IS_ENABLED(CONFIG_CFI_CLANG) && IS_ENABLED(CONFIG_MODULES))) { /* Generic SCL recovery */ if (!bri->set_scl || !bri->get_scl) { err_str = "no {get|set}_scl() found";