Re: [linux-next:master 12681/13861] drivers/i2c/i2c-core-base.o: warning: objtool: __i2c_transfer+0x120: stack state mismatch: reg1[24]=-1+0 reg2[24]=-2-24
From: Tiezhu Yang
Date: Tue Apr 08 2025 - 05:36:58 EST
On 04/08/2025 02:29 PM, Josh Poimboeuf wrote:
On Tue, Apr 08, 2025 at 10:45:51AM +0800, Tiezhu Yang wrote:
So this is a run-time bug rather than a compile-time warning, it should
put the option "-fno-shrink-wrap" outside CONFIG_OBJTOOL in
arch/loongarch/Makefile as a workaround, like this:
If loongarch folks agree it's a compiler bug, it should be reported to
GCC, so the issue is better understood (and can get fixed).
Without understanding the root cause, we don't know if -fno-shrink-wrap
fixes it, or just makes this particular occurrence go away.
OK, thank you. I have discussed offline with the developers
Rui Wang and Lulu Cheng who are familiar with compiler, the
root cause may be that if a jump label's control flow path
exactly matches the caller's epilogue, the compiler may omit
restoring saved registers, it needs to be confirmed by GCC
developers.
By the way, add an empty inline assembly can also work around
the problem, like this:
diff --git a/arch/loongarch/include/asm/jump_label.h
b/arch/loongarch/include/asm/jump_label.h
index 8a924bd69d19..dbc105e62380 100644
--- a/arch/loongarch/include/asm/jump_label.h
+++ b/arch/loongarch/include/asm/jump_label.h
@@ -34,6 +34,7 @@ static __always_inline bool arch_static_branch(struct
static_key * const key, co
return false;
l_yes:
+ asm volatile("");
return true;
}
@@ -47,6 +48,7 @@ static __always_inline bool
arch_static_branch_jump(struct static_key * const ke
return false;
l_yes:
+ asm volatile("");
return true;
}
We will fix this issue once the root cause is clear.
Thanks,
Tiezhu