:::::: 
:::::: Manual check reason: "low confidence static check warning: 
arch/x86/kernel/fpu/xstate.c:605:7: warning: Redundant initialization for 
'size'. The initialized value is overwritten before it is read. 
[redundantInitialization]"
:::::: 

BCC: l...@intel.com
CC: kbuild-...@lists.01.org
CC: linux-ker...@vger.kernel.org
TO: Thomas Gleixner <t...@linutronix.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   eb555cb5b794f4e12a9897f3d46d5a72104cd4a7
commit: 8ad7e8f696951f192c6629a0cbda9ac94c773159 x86/fpu/xsave: Support XSAVEC 
in the kernel
date:   4 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 4 months ago
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 8ad7e8f696951f192c6629a0cbda9ac94c773159
        cppcheck --quiet --enable=style,performance,portability --template=gcc 
FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <l...@intel.com>

cppcheck warnings: (new ones prefixed by >>)
   arch/x86/kernel/fpu/xstate.c:1236:7: warning: Local variable 'mask' shadows 
outer variable [shadowVariable]
     u64 mask = ((u64)1 << i);
         ^
   arch/x86/kernel/fpu/xstate.c:1205:6: note: Shadowed declaration
    u64 mask;
        ^
   arch/x86/kernel/fpu/xstate.c:1236:7: note: Shadow variable
     u64 mask = ((u64)1 << i);
         ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> arch/x86/kernel/fpu/xstate.c:605:7: warning: Redundant initialization for 
>> 'size'. The initialized value is overwritten before it is read. 
>> [redundantInitialization]
    size = xstate_calculate_size(fpu_kernel_cfg.max_features, compacted);
         ^
   arch/x86/kernel/fpu/xstate.c:590:20: note: size is initialized
    unsigned int size = FXSAVE_SIZE + XSAVE_HDR_SIZE;
                      ^
   arch/x86/kernel/fpu/xstate.c:605:7: note: size is overwritten
    size = xstate_calculate_size(fpu_kernel_cfg.max_features, compacted);
         ^
>> arch/x86/kernel/fpu/xstate.c:589:7: warning: Local variable 'xsaves' shadows 
>> outer function [shadowFunction]
    bool xsaves = cpu_feature_enabled(X86_FEATURE_XSAVES);
         ^
   arch/x86/kernel/fpu/xstate.c:1310:6: note: Shadowed declaration
   void xsaves(struct xregs_state *xstate, u64 mask)
        ^
   arch/x86/kernel/fpu/xstate.c:589:7: note: Shadow variable
    bool xsaves = cpu_feature_enabled(X86_FEATURE_XSAVES);
         ^
   arch/x86/kernel/fpu/xstate.c:1708:43: warning: Parameter 'tsk' can be 
declared with const [constParameter]
   long fpu_xstate_prctl(struct task_struct *tsk, int option, unsigned long 
arg2)
                                             ^

vim +/size +605 arch/x86/kernel/fpu/xstate.c

84e4dccc8fce20 Chang S. Bae    2021-10-21  576  
65ac2e9baa7dee Dave Hansen     2015-09-02  577  /*
65ac2e9baa7dee Dave Hansen     2015-09-02  578   * This essentially 
double-checks what the cpu told us about
65ac2e9baa7dee Dave Hansen     2015-09-02  579   * how large the XSAVE buffer 
needs to be.  We are recalculating
65ac2e9baa7dee Dave Hansen     2015-09-02  580   * it to be safe.
76d10256a97a7c Kan Liang       2020-07-20  581   *
01707b66535872 Andy Lutomirski 2021-06-23  582   * Independent XSAVE features 
allocate their own buffers and are not
76d10256a97a7c Kan Liang       2020-07-20  583   * covered by these checks. 
Only the size of the buffer for task->fpu
76d10256a97a7c Kan Liang       2020-07-20  584   * is checked here.
65ac2e9baa7dee Dave Hansen     2015-09-02  585   */
cd9ae761744912 Thomas Gleixner 2021-10-15  586  static bool __init 
paranoid_xstate_size_valid(unsigned int kernel_size)
65ac2e9baa7dee Dave Hansen     2015-09-02  587  {
8ad7e8f696951f Thomas Gleixner 2022-04-04  588          bool compacted = 
cpu_feature_enabled(X86_FEATURE_XCOMPACTED);
8ad7e8f696951f Thomas Gleixner 2022-04-04 @589          bool xsaves = 
cpu_feature_enabled(X86_FEATURE_XSAVES);
cd9ae761744912 Thomas Gleixner 2021-10-15  590          unsigned int size = 
FXSAVE_SIZE + XSAVE_HDR_SIZE;
65ac2e9baa7dee Dave Hansen     2015-09-02  591          int i;
65ac2e9baa7dee Dave Hansen     2015-09-02  592  
1c253ff2287fe3 Thomas Gleixner 2021-10-15  593          
for_each_extended_xfeature(i, fpu_kernel_cfg.max_features) {
cd9ae761744912 Thomas Gleixner 2021-10-15  594                  if 
(!check_xstate_against_struct(i))
cd9ae761744912 Thomas Gleixner 2021-10-15  595                          return 
false;
65ac2e9baa7dee Dave Hansen     2015-09-02  596                  /*
65ac2e9baa7dee Dave Hansen     2015-09-02  597                   * Supervisor 
state components can be managed only by
02b93c0b00df22 Thomas Gleixner 2021-06-23  598                   * XSAVES.
65ac2e9baa7dee Dave Hansen     2015-09-02  599                   */
8ad7e8f696951f Thomas Gleixner 2022-04-04  600                  if (!xsaves && 
xfeature_is_supervisor(i)) {
cd9ae761744912 Thomas Gleixner 2021-10-15  601                          
XSTATE_WARN_ON(1);
cd9ae761744912 Thomas Gleixner 2021-10-15  602                          return 
false;
cd9ae761744912 Thomas Gleixner 2021-10-15  603                  }
65ac2e9baa7dee Dave Hansen     2015-09-02  604          }
84e4dccc8fce20 Chang S. Bae    2021-10-21 @605          size = 
xstate_calculate_size(fpu_kernel_cfg.max_features, compacted);
cd9ae761744912 Thomas Gleixner 2021-10-15  606          XSTATE_WARN_ON(size != 
kernel_size);
cd9ae761744912 Thomas Gleixner 2021-10-15  607          return size == 
kernel_size;
65ac2e9baa7dee Dave Hansen     2015-09-02  608  }
65ac2e9baa7dee Dave Hansen     2015-09-02  609  

:::::: The code at line 605 was first introduced by commit
:::::: 84e4dccc8fce20b497388d756e12de5c9006eb48 x86/fpu/xstate: Provide 
xstate_calculate_size()

:::::: TO: Chang S. Bae <chang.seok....@intel.com>
:::::: CC: Borislav Petkov <b...@suse.de>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to