linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [hyperv:hyperv-next 4/5] drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type
@ 2021-12-18 10:20 kernel test robot
  2021-12-19 12:29 ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2021-12-18 10:20 UTC (permalink / raw)
  To: Tianyu Lan
  Cc: llvm, kbuild-all, linux-kernel, Wei Liu, Long Li, Michael Kelley

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
head:   19fd7ca00201c0525452dcf5a490e4b01674ef4c
commit: 6327882f7b4a476ea902de4bee5657f1028d6859 [4/5] scsi: storvsc: Add Isolation VM support for storvsc driver
config: x86_64-randconfig-a013-20211216 (https://download.01.org/0day-ci/archive/20211218/202112181827.o3X7GmHz-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4c9e31a4814592bbda7153833e46728dc7b21100)
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
        # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=6327882f7b4a476ea902de4bee5657f1028d6859
        git remote add hyperv https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
        git fetch --no-tags hyperv hyperv-next
        git checkout 6327882f7b4a476ea902de4bee5657f1028d6859
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/hv/

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

All warnings (new ones prefixed by >>):

>> drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type [-Wshift-count-overflow]
   static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
                               ^~~~~~~~~~~~~~~~
   include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
   #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
                                                        ^ ~~~
   1 warning generated.


vim +2082 drivers/hv/vmbus_drv.c

  2081	
> 2082	static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
  2083	/*
  2084	 * vmbus_device_register - Register the child device
  2085	 */
  2086	int vmbus_device_register(struct hv_device *child_device_obj)
  2087	{
  2088		struct kobject *kobj = &child_device_obj->device.kobj;
  2089		int ret;
  2090	
  2091		dev_set_name(&child_device_obj->device, "%pUl",
  2092			     &child_device_obj->channel->offermsg.offer.if_instance);
  2093	
  2094		child_device_obj->device.bus = &hv_bus;
  2095		child_device_obj->device.parent = &hv_acpi_dev->dev;
  2096		child_device_obj->device.release = vmbus_device_release;
  2097	
  2098		/*
  2099		 * Register with the LDM. This will kick off the driver/device
  2100		 * binding...which will eventually call vmbus_match() and vmbus_probe()
  2101		 */
  2102		ret = device_register(&child_device_obj->device);
  2103		if (ret) {
  2104			pr_err("Unable to register child device\n");
  2105			return ret;
  2106		}
  2107	
  2108		child_device_obj->channels_kset = kset_create_and_add("channels",
  2109								      NULL, kobj);
  2110		if (!child_device_obj->channels_kset) {
  2111			ret = -ENOMEM;
  2112			goto err_dev_unregister;
  2113		}
  2114	
  2115		ret = vmbus_add_channel_kobj(child_device_obj,
  2116					     child_device_obj->channel);
  2117		if (ret) {
  2118			pr_err("Unable to register primary channeln");
  2119			goto err_kset_unregister;
  2120		}
  2121		hv_debug_add_dev_dir(child_device_obj);
  2122	
  2123		child_device_obj->device.dma_mask = &vmbus_dma_mask;
  2124		child_device_obj->device.dma_parms = &child_device_obj->dma_parms;
  2125		return 0;
  2126	
  2127	err_kset_unregister:
  2128		kset_unregister(child_device_obj->channels_kset);
  2129	
  2130	err_dev_unregister:
  2131		device_unregister(&child_device_obj->device);
  2132		return ret;
  2133	}
  2134	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

* Re: [hyperv:hyperv-next 4/5] drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type
  2021-12-18 10:20 [hyperv:hyperv-next 4/5] drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type kernel test robot
@ 2021-12-19 12:29 ` Wei Liu
  2021-12-20 16:53   ` Nathan Chancellor
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2021-12-19 12:29 UTC (permalink / raw)
  To: kernel test robot
  Cc: Tianyu Lan, llvm, kbuild-all, linux-kernel, Wei Liu, Long Li,
	Michael Kelley

On Sat, Dec 18, 2021 at 06:20:43PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
> head:   19fd7ca00201c0525452dcf5a490e4b01674ef4c
> commit: 6327882f7b4a476ea902de4bee5657f1028d6859 [4/5] scsi: storvsc: Add Isolation VM support for storvsc driver
> config: x86_64-randconfig-a013-20211216 (https://download.01.org/0day-ci/archive/20211218/202112181827.o3X7GmHz-lkp@intel.com/config)
> compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4c9e31a4814592bbda7153833e46728dc7b21100)
> 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
>         # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=6327882f7b4a476ea902de4bee5657f1028d6859
>         git remote add hyperv https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
>         git fetch --no-tags hyperv hyperv-next
>         git checkout 6327882f7b4a476ea902de4bee5657f1028d6859
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/hv/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
> >> drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type [-Wshift-count-overflow]
>    static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
>                                ^~~~~~~~~~~~~~~~
>    include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
>    #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
>                                                         ^ ~~~

I don't think there is anything wrong with the code. When n is 64 the
problematic expression is not evaluated.

Wei.

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

* Re: [hyperv:hyperv-next 4/5] drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type
  2021-12-19 12:29 ` Wei Liu
@ 2021-12-20 16:53   ` Nathan Chancellor
  2021-12-20 17:44     ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2021-12-20 16:53 UTC (permalink / raw)
  To: Wei Liu
  Cc: kernel test robot, Tianyu Lan, llvm, kbuild-all, linux-kernel,
	Long Li, Michael Kelley

Hi Wei,

On Sun, Dec 19, 2021 at 12:29:37PM +0000, Wei Liu wrote:
> On Sat, Dec 18, 2021 at 06:20:43PM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
> > head:   19fd7ca00201c0525452dcf5a490e4b01674ef4c
> > commit: 6327882f7b4a476ea902de4bee5657f1028d6859 [4/5] scsi: storvsc: Add Isolation VM support for storvsc driver
> > config: x86_64-randconfig-a013-20211216 (https://download.01.org/0day-ci/archive/20211218/202112181827.o3X7GmHz-lkp@intel.com/config)
> > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4c9e31a4814592bbda7153833e46728dc7b21100)
> > 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
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=6327882f7b4a476ea902de4bee5657f1028d6859
> >         git remote add hyperv https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
> >         git fetch --no-tags hyperv hyperv-next
> >         git checkout 6327882f7b4a476ea902de4bee5657f1028d6859
> >         # save the config file to linux build tree
> >         mkdir build_dir
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/hv/
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > 
> > All warnings (new ones prefixed by >>):
> > 
> > >> drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type [-Wshift-count-overflow]
> >    static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> >                                ^~~~~~~~~~~~~~~~
> >    include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
> >    #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> >                                                         ^ ~~~
> 
> I don't think there is anything wrong with the code. When n is 64 the
> problematic expression is not evaluated.

Yes, unfortunately, this is an outstanding bug in clang where it does
not properly build a control flow graph for expressions at a global
scope:

https://github.com/ClangBuiltLinux/linux/issues/92

We should absolutely fix that but it has not come up too often so other
fires have been prioritized. Now that -Werror is a thing, that issue's
priority should probably be upgraded, as this warning will break
allmodconfig for clang.

If you were feeling generous, just changing that to ~0ULL directly would
solve the warning but I get that it is less documentation that way.

Cheers,
Nathan

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

* Re: [hyperv:hyperv-next 4/5] drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type
  2021-12-20 16:53   ` Nathan Chancellor
@ 2021-12-20 17:44     ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2021-12-20 17:44 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Wei Liu, kernel test robot, Tianyu Lan, llvm, kbuild-all,
	linux-kernel, Long Li, Michael Kelley

On Mon, Dec 20, 2021 at 09:53:30AM -0700, Nathan Chancellor wrote:
> Hi Wei,
> 
> On Sun, Dec 19, 2021 at 12:29:37PM +0000, Wei Liu wrote:
> > On Sat, Dec 18, 2021 at 06:20:43PM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
> > > head:   19fd7ca00201c0525452dcf5a490e4b01674ef4c
> > > commit: 6327882f7b4a476ea902de4bee5657f1028d6859 [4/5] scsi: storvsc: Add Isolation VM support for storvsc driver
> > > config: x86_64-randconfig-a013-20211216 (https://download.01.org/0day-ci/archive/20211218/202112181827.o3X7GmHz-lkp@intel.com/config)
> > > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4c9e31a4814592bbda7153833e46728dc7b21100)
> > > 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
> > >         # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=6327882f7b4a476ea902de4bee5657f1028d6859
> > >         git remote add hyperv https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
> > >         git fetch --no-tags hyperv hyperv-next
> > >         git checkout 6327882f7b4a476ea902de4bee5657f1028d6859
> > >         # save the config file to linux build tree
> > >         mkdir build_dir
> > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/hv/
> > > 
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > 
> > > All warnings (new ones prefixed by >>):
> > > 
> > > >> drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type [-Wshift-count-overflow]
> > >    static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> > >                                ^~~~~~~~~~~~~~~~
> > >    include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
> > >    #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> > >                                                         ^ ~~~
> > 
> > I don't think there is anything wrong with the code. When n is 64 the
> > problematic expression is not evaluated.
> 
> Yes, unfortunately, this is an outstanding bug in clang where it does
> not properly build a control flow graph for expressions at a global
> scope:
> 
> https://github.com/ClangBuiltLinux/linux/issues/92
> 
> We should absolutely fix that but it has not come up too often so other
> fires have been prioritized. Now that -Werror is a thing, that issue's
> priority should probably be upgraded, as this warning will break
> allmodconfig for clang.

Thanks for the explanation.

> 
> If you were feeling generous, just changing that to ~0ULL directly would
> solve the warning but I get that it is less documentation that way.

I would actually like to keep the code as-is because it gives a clear
idea what it is doing.

Wei.

> 
> Cheers,
> Nathan

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

end of thread, other threads:[~2021-12-20 17:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18 10:20 [hyperv:hyperv-next 4/5] drivers/hv/vmbus_drv.c:2082:29: warning: shift count >= width of type kernel test robot
2021-12-19 12:29 ` Wei Liu
2021-12-20 16:53   ` Nathan Chancellor
2021-12-20 17:44     ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).