public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]'
@ 2023-10-18 17:22 kernel test robot
  2023-10-20  9:15 ` JeeHeng Sia
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2023-10-18 17:22 UTC (permalink / raw)
  To: Sia Jee Heng
  Cc: oe-kbuild-all, linux-kernel, Palmer Dabbelt, Ley Foon Tan,
	Mason Huo, Conor Dooley, Andrew Jones

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   06dc10eae55b5ceabfef287a7e5f16ceea204aa0
commit: c0317210012e3b985779ddd92a7c5db8424e1e97 RISC-V: Add arch functions to support hibernation/suspend-to-disk
date:   6 months ago
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20231019/202310190159.mAUo9iEX-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310190159.mAUo9iEX-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310190159.mAUo9iEX-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/riscv/include/asm/page.h:12,
                    from arch/riscv/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:60,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/riscv/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:56,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:7,
                    from include/linux/mm.h:7,
                    from arch/riscv/include/asm/cacheflush.h:9,
                    from arch/riscv/kernel/hibernate.c:11:
   arch/riscv/kernel/hibernate.c: In function 'pfn_is_nosave':
>> arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]' [-Warray-bounds=]
      76 |         unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);
   include/linux/pfn.h:22:43: note: in definition of macro 'PHYS_PFN'
      22 | #define PHYS_PFN(x)     ((unsigned long)((x) >> PAGE_SHIFT))
         |                                           ^
   arch/riscv/include/asm/page.h:172:33: note: in expansion of macro '__phys_to_pfn'
     172 | #define sym_to_pfn(x)           __phys_to_pfn(__pa_symbol(x))
         |                                 ^~~~~~~~~~~~~
   arch/riscv/include/asm/page.h:156:44: note: in expansion of macro 'RELOC_HIDE'
     156 | #define __pa_symbol(x)  __phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0))
         |                                            ^~~~~~~~~~
   arch/riscv/include/asm/page.h:172:47: note: in expansion of macro '__pa_symbol'
     172 | #define sym_to_pfn(x)           __phys_to_pfn(__pa_symbol(x))
         |                                               ^~~~~~~~~~~
   arch/riscv/kernel/hibernate.c:76:40: note: in expansion of macro 'sym_to_pfn'
      76 |         unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);
         |                                        ^~~~~~~~~~
   In file included from arch/riscv/include/asm/sections.h:8,
                    from include/linux/interrupt.h:21,
                    from include/linux/kernel_stat.h:9,
                    from include/linux/cgroup.h:26,
                    from include/linux/memcontrol.h:13,
                    from include/linux/swap.h:9,
                    from include/asm-generic/tlb.h:15,
                    from arch/riscv/include/asm/tlb.h:14,
                    from arch/riscv/include/asm/pgalloc.h:11,
                    from arch/riscv/kernel/hibernate.c:14:
   include/asm-generic/sections.h:59:45: note: at offset -1 into object '__nosave_end' of size [0, 9223372036854775807]
      59 | extern __visible const void __nosave_begin, __nosave_end;
         |                                             ^~~~~~~~~~~~


vim +76 arch/riscv/kernel/hibernate.c

    69	
    70	/*
    71	 * Check if the given pfn is in the 'nosave' section.
    72	 */
    73	int pfn_is_nosave(unsigned long pfn)
    74	{
    75		unsigned long nosave_begin_pfn = sym_to_pfn(&__nosave_begin);
  > 76		unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);
    77	
    78		return ((pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn));
    79	}
    80	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]'
  2023-10-18 17:22 arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]' kernel test robot
@ 2023-10-20  9:15 ` JeeHeng Sia
  0 siblings, 0 replies; 2+ messages in thread
From: JeeHeng Sia @ 2023-10-20  9:15 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Palmer Dabbelt, Leyfoon Tan, Mason Huo, Conor Dooley,
	Andrew Jones

Hi,

I followed the reproduction steps provided at the link: https://download.01.org/0day-ci/archive/20231019/202310190159.mAUo9iEX-lkp@intel.com/reproduce to download the Linux kernel, compiler version, and the config found here: https://download.01.org/0day-ci/archive/20231019/202310190159.mAUo9iEX-lkp@intel.com/config.
Indeed, I was able to reproduce the issue, but only with kernel v6.3-rc1.

When I tested with the same compiler version and config on kernel v6.6-rc6, I found no issues. Given these findings, do you believe it's still necessary to address the problem?

Thanks
Regards
Jee Heng

> -----Original Message-----
> From: kernel test robot <lkp@intel.com>
> Sent: Thursday, October 19, 2023 1:23 AM
> To: JeeHeng Sia <jeeheng.sia@starfivetech.com>
> Cc: oe-kbuild-all@lists.linux.dev; linux-kernel@vger.kernel.org; Palmer Dabbelt <palmer@rivosinc.com>; Leyfoon Tan
> <leyfoon.tan@starfivetech.com>; Mason Huo <mason.huo@starfivetech.com>; Conor Dooley <conor.dooley@microchip.com>;
> Andrew Jones <ajones@ventanamicro.com>
> Subject: arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]'
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   06dc10eae55b5ceabfef287a7e5f16ceea204aa0
> commit: c0317210012e3b985779ddd92a7c5db8424e1e97 RISC-V: Add arch functions to support hibernation/suspend-to-disk
> date:   6 months ago
> config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20231019/202310190159.mAUo9iEX-lkp@intel.com/config)
> compiler: riscv64-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310190159.mAUo9iEX-
> lkp@intel.com/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@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202310190159.mAUo9iEX-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from arch/riscv/include/asm/page.h:12,
>                     from arch/riscv/include/asm/thread_info.h:11,
>                     from include/linux/thread_info.h:60,
>                     from include/asm-generic/preempt.h:5,
>                     from ./arch/riscv/include/generated/asm/preempt.h:1,
>                     from include/linux/preempt.h:78,
>                     from include/linux/spinlock.h:56,
>                     from include/linux/mmzone.h:8,
>                     from include/linux/gfp.h:7,
>                     from include/linux/mm.h:7,
>                     from arch/riscv/include/asm/cacheflush.h:9,
>                     from arch/riscv/kernel/hibernate.c:11:
>    arch/riscv/kernel/hibernate.c: In function 'pfn_is_nosave':
> >> arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]' [-Warray-bounds=]
>       76 |         unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);
>    include/linux/pfn.h:22:43: note: in definition of macro 'PHYS_PFN'
>       22 | #define PHYS_PFN(x)     ((unsigned long)((x) >> PAGE_SHIFT))
>          |                                           ^
>    arch/riscv/include/asm/page.h:172:33: note: in expansion of macro '__phys_to_pfn'
>      172 | #define sym_to_pfn(x)           __phys_to_pfn(__pa_symbol(x))
>          |                                 ^~~~~~~~~~~~~
>    arch/riscv/include/asm/page.h:156:44: note: in expansion of macro 'RELOC_HIDE'
>      156 | #define __pa_symbol(x)  __phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0))
>          |                                            ^~~~~~~~~~
>    arch/riscv/include/asm/page.h:172:47: note: in expansion of macro '__pa_symbol'
>      172 | #define sym_to_pfn(x)           __phys_to_pfn(__pa_symbol(x))
>          |                                               ^~~~~~~~~~~
>    arch/riscv/kernel/hibernate.c:76:40: note: in expansion of macro 'sym_to_pfn'
>       76 |         unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);
>          |                                        ^~~~~~~~~~
>    In file included from arch/riscv/include/asm/sections.h:8,
>                     from include/linux/interrupt.h:21,
>                     from include/linux/kernel_stat.h:9,
>                     from include/linux/cgroup.h:26,
>                     from include/linux/memcontrol.h:13,
>                     from include/linux/swap.h:9,
>                     from include/asm-generic/tlb.h:15,
>                     from arch/riscv/include/asm/tlb.h:14,
>                     from arch/riscv/include/asm/pgalloc.h:11,
>                     from arch/riscv/kernel/hibernate.c:14:
>    include/asm-generic/sections.h:59:45: note: at offset -1 into object '__nosave_end' of size [0, 9223372036854775807]
>       59 | extern __visible const void __nosave_begin, __nosave_end;
>          |                                             ^~~~~~~~~~~~
> 
> 
> vim +76 arch/riscv/kernel/hibernate.c
> 
>     69
>     70	/*
>     71	 * Check if the given pfn is in the 'nosave' section.
>     72	 */
>     73	int pfn_is_nosave(unsigned long pfn)
>     74	{
>     75		unsigned long nosave_begin_pfn = sym_to_pfn(&__nosave_begin);
>   > 76		unsigned long nosave_end_pfn = sym_to_pfn(&__nosave_end - 1);
>     77
>     78		return ((pfn >= nosave_begin_pfn) && (pfn <= nosave_end_pfn));
>     79	}
>     80
> 
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-20  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-18 17:22 arch/riscv/kernel/hibernate.c:76:65: warning: array subscript -1 is outside array bounds of 'const void[]' kernel test robot
2023-10-20  9:15 ` JeeHeng Sia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox