From: Zhipeng Wang <zhipeng.wang_1@nxp.com>
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 [thread overview]
Message-ID: <20220628024155.2135990-1-zhipeng.wang_1@nxp.com> (raw)
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 <zhipeng.wang_1@nxp.com>
---
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";
--
2.25.1
next reply other threads:[~2022-06-28 2:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 2:41 Zhipeng Wang [this message]
2022-06-29 19:28 ` [PATCH] i2c: core: Disable i2c_generic_scl_recovery callback checks with CFI Wolfram Sang
2022-06-30 6:20 ` [EXT] " Zhipeng Wang
2022-06-30 15:54 ` Sami Tolvanen
2022-07-01 6:32 ` [EXT] " Zhipeng Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220628024155.2135990-1-zhipeng.wang_1@nxp.com \
--to=zhipeng.wang_1@nxp.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox