Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2496137pxb; Tue, 24 Aug 2021 00:01:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKZ3gcc9CprKZgI9Kc6q6Atde/pKB6xl9Mo/vcAFB2rtf4+yIOooYnwdUKHpcf2+aywy2Q X-Received: by 2002:a50:cc05:: with SMTP id m5mr39102213edi.9.1629788481707; Tue, 24 Aug 2021 00:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629788481; cv=none; d=google.com; s=arc-20160816; b=BEx8d2sLIfHM5npAzRQ27kvkSDNo/2fCabDMNP0q/2C+KUe/UFoRu8nYp4z8voIvYe 1BNIEGornwV+rqSa4X10XdyV8wjl6UZQ+OsgRG8tqLuEYCzjei/SxmigSc6ikM5pwWRf /NceHWnK9iMb99dDY/kJVD+k4lFD8A86kMiDDVVxrCtIHhxaKKxlwHmt5lzsZLSUn5gs KdQx29XOk+i5S3NokBQRWGhwaNYELqLvjmqu0l0g5T5z3Cx9C45DUDcYoTrOxnmCDNVQ 1w2D7+LM1Hep+YD0FPpIvwWkLybCwycxL5pnF/cVO83uzWMuSI2yRHXAzoO3Hq6nsjYv jHeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=jWqzm5sZ+IHl6hnvathNn+SDcEPN1urkarNvn3kASvM=; b=Y8cyp0l72iO0zzZNSKn0W0/OIT7itvjoF6/5LOetN7dd+GhuF0YuhiKLfk33nZeUM0 zXIIIn6C8F86jDbwK0QbN1XHT8zzAuvn5LCH4wgL2bmWqL57oAZR54usgMF01K7iBp9t AjfsgGBNSdtqnIAUPYc9k752ihASFThPUp1jqhg3Jt/gaT/7z7/qfgEb1SabsCV/p3Zz sUvf1APa6M8Su5Pvj0sXSSh3tDVoi8JHOf+eJ2Mwsgwx+ufdxDDxxgugobqrxMVWg+4g /KGCM2Kt/UPkEkdVyAi7NSBb16RY/hEZdRxhkeiwRCXO+SkNMGQks4HsWTv/jn50t09F CFFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx14si17226073edb.407.2021.08.24.00.00.58; Tue, 24 Aug 2021 00:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233288AbhHXHAQ (ORCPT + 99 others); Tue, 24 Aug 2021 03:00:16 -0400 Received: from mga03.intel.com ([134.134.136.65]:29331 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbhHXHAN (ORCPT ); Tue, 24 Aug 2021 03:00:13 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10085"; a="217277454" X-IronPort-AV: E=Sophos;i="5.84,346,1620716400"; d="scan'208";a="217277454" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2021 23:59:28 -0700 X-IronPort-AV: E=Sophos;i="5.84,346,1620716400"; d="scan'208";a="526502052" Received: from rongch2-mobl.ccr.corp.intel.com (HELO [10.249.172.62]) ([10.249.172.62]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2021 23:59:26 -0700 Subject: Re: [kbuild-all] Re: arch/powerpc/kernel/signal_32.c:297:2: warning: Value stored to 'msr' is never read [clang-analyzer-deadcode.DeadStores] To: Christophe Leroy , kernel test robot Cc: clang-built-linux@googlegroups.com, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Michael Ellerman References: <202108231827.N9VUIKbD-lkp@intel.com> <3db8de6e-a971-be9f-19eb-e7d95faf2870@csgroup.eu> From: "Chen, Rong A" Message-ID: <7955eec5-c1d7-e0d7-280a-138d96b2daa9@intel.com> Date: Tue, 24 Aug 2021 14:59:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <3db8de6e-a971-be9f-19eb-e7d95faf2870@csgroup.eu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> >> >> 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. Best Regards, Rong Chen > > > > > >> ??? arch/powerpc/kernel/signal_32.c:765:16: warning: Value stored to >> 'msr' during its initialization is never read >> [clang-analyzer-deadcode.DeadStores] >> ??????????? unsigned long msr = regs->msr; >> ????????????????????????? ^~~?? ~~~~~~~~~ >> ??? arch/powerpc/kernel/signal_32.c:765:16: note: Value stored to >> 'msr' during its initialization is never read >> ??????????? unsigned long msr = regs->msr; >> ????????????????????????? ^~~?? ~~~~~~~~~ >> ??? arch/powerpc/kernel/signal_32.c:869:16: warning: Value stored to >> 'msr' during its initialization is never read >> [clang-analyzer-deadcode.DeadStores] >> ??????????? unsigned long msr = regs->msr; >> ????????????????????????? ^~~?? ~~~~~~~~~ >> ??? arch/powerpc/kernel/signal_32.c:869:16: note: Value stored to >> 'msr' during its initialization is never read >> ??????????? unsigned long msr = regs->msr; >> ????????????????????????? ^~~?? ~~~~~~~~~ >> >> vim +/msr +297 arch/powerpc/kernel/signal_32.c >> >> 968c4fccd1bb8b arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 262 >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 263? static int save_user_regs_unsafe(struct pt_regs >> *regs, struct mcontext __user *frame, >> 8d33001dd650b8 arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 264?????????????????? struct mcontext __user *tm_frame, >> int ctx_has_vsx_region) >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 265? { >> 9e7511861c4f8d arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 266????? unsigned long msr = regs->msr; >> 9e7511861c4f8d arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 267 >> c6e6771b87d4e3 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 268????? /* save general registers */ >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 269????? unsafe_save_general_regs(regs, frame, failed); >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 270 >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 271? #ifdef CONFIG_ALTIVEC >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 272????? /* save altivec registers */ >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 273????? if (current->thread.used_vr) { >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 274????????? unsafe_copy_to_user(&frame->mc_vregs, >> ¤t->thread.vr_state, >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 275????????????????????? ELF_NVRREG * sizeof(vector128), >> failed); >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 276????????? /* set MSR_VEC in the saved MSR value to >> indicate that >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 277???????????? frame->mc_vregs contains valid data */ >> 9e7511861c4f8d arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 278????????? msr |= MSR_VEC; >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 279????? } >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 280????? /* else assert((regs->msr & MSR_VEC) == 0) */ >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 281 >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 282????? /* We always copy to/from vrsave, it's 0 if we >> don't have or don't >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 283?????? * use altivec. Since VSCR only contains 32 bits >> saved in the least >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 284?????? * significant bits of a vector, we "cheat" and >> stuff VRSAVE in the >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 285?????? * most significant bits of that same vector. --BenH >> 408a7e08b2112f arch/powerpc/kernel/signal_32.c Paul Mackerras >> 2013-08-05? 286?????? * Note that the current VRSAVE value is in the >> SPR at this point. >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 287?????? */ >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 288????? unsafe_put_user(current->thread.vrsave, (u32 >> __user *)&frame->mc_vregs[32], >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 289????????????? failed); >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 290? #endif /* CONFIG_ALTIVEC */ >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 291????? unsafe_copy_fpr_to_user(&frame->mc_fregs, >> current, failed); >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25? 292 >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25? 293????? /* >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25? 294?????? * Clear the MSR VSX bit to indicate there is no >> valid state attached >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25? 295?????? * to this context, except in the specific case >> below where we set it. >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25? 296?????? */ >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25 @297????? msr &= ~MSR_VSX; >> 6a274c08f2f4df arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-07-02? 298? #ifdef CONFIG_VSX >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 299????? /* >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 300?????? * Copy VSR 0-31 upper half from thread_struct to >> local >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 301?????? * buffer, then write that to userspace.? Also >> set MSR_VSX in >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 302?????? * the saved MSR value to indicate that >> frame->mc_vregs >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 303?????? * contains valid data >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 304?????? */ >> 16c29d180becc5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-10-23? 305????? if (current->thread.used_vsr && >> ctx_has_vsx_region) { >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 306????????? unsafe_copy_vsx_to_user(&frame->mc_vsregs, >> current, failed); >> ce48b2100785e5 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 307????????? msr |= MSR_VSX; >> ec67ad82814bee arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-11-25? 308????? } >> c6e6771b87d4e3 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 309? #endif /* CONFIG_VSX */ >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 310? #ifdef CONFIG_SPE >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 311????? /* save spe registers */ >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 312????? if (current->thread.used_spe) { >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 313????????? unsafe_copy_to_user(&frame->mc_vregs, >> current->thread.evr, >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 314????????????????????? ELF_NEVRREG * sizeof(u32), failed); >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 315????????? /* set MSR_SPE in the saved MSR value to >> indicate that >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 316???????????? frame->mc_vregs contains valid data */ >> 9e7511861c4f8d arch/powerpc/kernel/signal_32.c Michael Neuling >> 2008-06-25? 317????????? msr |= MSR_SPE; >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 318????? } >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 319????? /* else assert((regs->msr & MSR_SPE) == 0) */ >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 320 >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 321????? /* We always copy to/from spefscr */ >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 322????? unsafe_put_user(current->thread.spefscr, >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 323????????????? (u32 __user *)&frame->mc_vregs + >> ELF_NEVRREG, failed); >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 324? #endif /* CONFIG_SPE */ >> 81e7009ea46c95 arch/powerpc/kernel/signal_32.c Stephen Rothwell >> 2005-10-18? 325 >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 326????? unsafe_put_user(msr, &frame->mc_gregs[PT_MSR], >> failed); >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 327 >> 1d25f11fdbcc53 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-06-09? 328????? /* We need to write 0 the MSR top 32 bits in the >> tm frame so that we >> 1d25f11fdbcc53 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-06-09? 329?????? * can check it on the restore to see if TM is >> active >> 1d25f11fdbcc53 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-06-09? 330?????? */ >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 331????? if (tm_frame) >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 332????????? unsafe_put_user(0, >> &tm_frame->mc_gregs[PT_MSR], failed); >> 1d25f11fdbcc53 arch/powerpc/kernel/signal_32.c Michael Neuling >> 2013-06-09? 333 >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 334????? return 0; >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 335 >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 336? failed: >> ef75e73182949a arch/powerpc/kernel/signal_32.c Christophe Leroy >> 2020-08-18? 337????? return 1; >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 338? } >> ^1da177e4c3f41 arch/ppc64/kernel/signal32.c??? Linus Torvalds >> 2005-04-16? 339 >> >> :::::: The code at line 297 was first introduced by commit >> :::::: ec67ad82814bee92251fd963bf01c7a173856555 powerpc/signals: >> Improved mark VSX not saved with small contexts fix >> >> :::::: TO: Michael Neuling >> :::::: CC: Benjamin Herrenschmidt >> >> --- >> 0-DAY CI Kernel Test Service, Intel Corporation >> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org >> > _______________________________________________ > kbuild-all mailing list -- kbuild-all@lists.01.org > To unsubscribe send an email to kbuild-all-leave@lists.01.org