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: Josh Poimboeuf
Date: Thu Apr 03 2025 - 10:41:36 EST


On Thu, Apr 03, 2025 at 05:35:51PM +0800, Tiezhu Yang wrote:
> On 04/02/2025 03:45 AM, Josh Poimboeuf wrote:
> > On Tue, Apr 01, 2025 at 12:38:37PM +0800, Philip Li wrote:
> > > On Tue, Apr 01, 2025 at 10:44:57AM +0800, kernel test robot wrote:
> > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > > > head: 405e2241def89c88f008dcb899eb5b6d4be8b43c
> > > > commit: 9016dad4dca4bbe61c48ffd5a273cad980caa0d1 [12681/13861] loongarch: add support for suppressing warning backtraces
> > > > config: loongarch-randconfig-001-20250401 (https://download.01.org/0day-ci/archive/20250401/202504011011.jyZ6NtXx-lkp@xxxxxxxxx/config)
> > > > compiler: loongarch64-linux-gcc (GCC) 14.2.0
> > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250401/202504011011.jyZ6NtXx-lkp@xxxxxxxxx/reproduce)
> > > >
> > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > > the same patch/commit), kindly add following tags
> > > > | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202504011011.jyZ6NtXx-lkp@xxxxxxxxx/
> > > >
> > > > All warnings (new ones prefixed by >>):
> > > >
> > > > > > drivers/i2c/i2c-core-base.o: warning: objtool: __i2c_transfer+0x120: stack state mismatch: reg1[24]=-1+0 reg2[24]=-2-24
> >
> > Tiezhu, this looks like a loongarch GCC bug with asm goto, or am I
> > confused? See analysis below.
>
> This is related with GCC optimization "-fshrink-wrap" which is default y
> on LoongArch, use "-fno-shrink-wrap" can avoid such issues, like this:

As I showed, it looks like an actual runtime bug, not an objtool false
positive. Disabling it only for CONFIG_OBJTOOLonly wouldn't fix that.

--
Josh