Re: [kbuild-all] Re: arch/powerpc/kernel/signal_32.c:297:2: warning: Value stored to 'msr' is never read [clang-analyzer-deadcode.DeadStores]

From: Rong Chen
Date: Wed Aug 25 2021 - 04:48:40 EST




On 8/24/21 3:29 PM, Christophe Leroy wrote:


Le 24/08/2021 à 08:59, Chen, Rong A a écrit :


On 8/23/2021 10:35 PM, Christophe Leroy wrote:


Le 23/08/2021 à 12:59, kernel test robot a écrit :
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e22ce8eb631bdc47a4a4ea7ecf4e4ba499db4f93
commit: ef75e73182949a94bde169a774de1b62ae21fbbc powerpc/signal32: Transform save_user_regs() and save_tm_user_regs() in 'unsafe' version
date:   9 months ago
config: powerpc-randconfig-c003-20210821 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d9c5613e856cf2addfbf892fc4c1ce9ef9feceaa)
reproduce (this is a W=1 build):
         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # install powerpc cross compiling tool for clang build
         # apt-get install binutils-powerpc-linux-gnu
         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ef75e73182949a94bde169a774de1b62ae21fbbc
         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
         git fetch --no-tags linus master
         git checkout ef75e73182949a94bde169a774de1b62ae21fbbc
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


clang-analyzer warnings: (new ones prefixed by >>)
            ^
arch/powerpc/kernel/signal_32.c:297:2: warning: Value stored to 'msr' is never read [clang-analyzer-deadcode.DeadStores]
            msr &= ~MSR_VSX;
            ^      ~~~~~~~~
    arch/powerpc/kernel/signal_32.c:297:2: note: Value stored to 'msr' is never read
            msr &= ~MSR_VSX;
            ^      ~~~~~~~~


This is wrong.

msr is used at line 326:

ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy 2020-08-18  326 unsafe_put_user(msr, &frame->mc_gregs[PT_MSR], failed);

Hi Christophe,

The usage is under CONFIG_VSX, the test config (powerpc-randconfig-c003-20210821) didn't enable it which triggered this warning.


No no, the 'unsafe_put_user(msr, &frame->mc_gregs[PT_MSR], failed) ' at line 326 is not under CONFIG_VSX as far as I can see.


Christophe

Hi Christophe,

It's my fault, I didn't see it correctly, and I have no idea why clang-analyzer reported it as a issue,
we'll double check such warning next time.

Best Regards,
Rong Chen