Re: [PATCH v3] xen-pciback: optionally allow interrupt enable flag writes
From: Nick Desaulniers
Date: Mon Jan 13 2020 - 12:11:56 EST
Hi Marek,
Below is a report from 0day bot build w/ Clang. The warning looks
legit, can you please take a look? Apologies if this has already been
reported.
On Sat, Jan 11, 2020 at 7:48 AM kbuild test robot <lkp@xxxxxxxxx> wrote:
>
> CC: kbuild-all@xxxxxxxxxxxx
> In-Reply-To: <20200111034347.5270-1-marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> References: <20200111034347.5270-1-marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> TO: "Marek Marczykowski-GÃrecki" <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> CC: xen-devel@xxxxxxxxxxxxxxxxxxxx, "Marek Marczykowski-GÃrecki" <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, YueHaibing <yuehaibing@xxxxxxxxxx>, open list <linux-kernel@xxxxxxxxxxxxxxx>, "Marek Marczykowski-GÃrecki" <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, YueHaibing <yuehaibing@xxxxxxxxxx>, open list <linux-kernel@xxxxxxxxxxxxxxx>
> CC: "Marek Marczykowski-GÃrecki" <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, YueHaibing <yuehaibing@xxxxxxxxxx>, open list <linux-kernel@xxxxxxxxxxxxxxx>
>
> Hi "Marek,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on xen-tip/linux-next]
> [also build test WARNING on linux/master linus/master v5.5-rc5 next-20200110]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
>
> url: https://github.com/0day-ci/linux/commits/Marek-Marczykowski-G-recki/xen-pciback-optionally-allow-interrupt-enable-flag-writes/20200111-162243
> base: https://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git linux-next
> config: x86_64-allyesconfig (attached as .config)
> compiler: clang version 10.0.0 (git://gitmirror/llvm_project 016bf03ef6fcd9dce43b0c17971f76323f07a684)
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@xxxxxxxxx>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/xen/xen-pciback/conf_space_header.c:121:19: warning: variable 'val' is uninitialized when used here [-Wuninitialized]
> if ((cmd->val ^ val) & PCI_COMMAND_INTX_DISABLE) {
> ^~~
> drivers/xen/xen-pciback/conf_space_header.c:65:9: note: initialize the variable 'val' to silence this warning
> u16 val;
> ^
> = 0
> 1 warning generated.
>
> vim +/val +121 drivers/xen/xen-pciback/conf_space_header.c
>
> 60
> 61 static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
> 62 {
> 63 struct xen_pcibk_dev_data *dev_data;
> 64 int err;
> 65 u16 val;
> 66 struct pci_cmd_info *cmd = data;
> 67
> 68 dev_data = pci_get_drvdata(dev);
> 69 if (!pci_is_enabled(dev) && is_enable_cmd(value)) {
> 70 if (unlikely(verbose_request))
> 71 printk(KERN_DEBUG DRV_NAME ": %s: enable\n",
> 72 pci_name(dev));
> 73 err = pci_enable_device(dev);
> 74 if (err)
> 75 return err;
> 76 if (dev_data)
> 77 dev_data->enable_intx = 1;
> 78 } else if (pci_is_enabled(dev) && !is_enable_cmd(value)) {
> 79 if (unlikely(verbose_request))
> 80 printk(KERN_DEBUG DRV_NAME ": %s: disable\n",
> 81 pci_name(dev));
> 82 pci_disable_device(dev);
> 83 if (dev_data)
> 84 dev_data->enable_intx = 0;
> 85 }
> 86
> 87 if (!dev->is_busmaster && is_master_cmd(value)) {
> 88 if (unlikely(verbose_request))
> 89 printk(KERN_DEBUG DRV_NAME ": %s: set bus master\n",
> 90 pci_name(dev));
> 91 pci_set_master(dev);
> 92 } else if (dev->is_busmaster && !is_master_cmd(value)) {
> 93 if (unlikely(verbose_request))
> 94 printk(KERN_DEBUG DRV_NAME ": %s: clear bus master\n",
> 95 pci_name(dev));
> 96 pci_clear_master(dev);
> 97 }
> 98
> 99 if (!(cmd->val & PCI_COMMAND_INVALIDATE) &&
> 100 (value & PCI_COMMAND_INVALIDATE)) {
> 101 if (unlikely(verbose_request))
> 102 printk(KERN_DEBUG
> 103 DRV_NAME ": %s: enable memory-write-invalidate\n",
> 104 pci_name(dev));
> 105 err = pci_set_mwi(dev);
> 106 if (err) {
> 107 pr_warn("%s: cannot enable memory-write-invalidate (%d)\n",
> 108 pci_name(dev), err);
> 109 value &= ~PCI_COMMAND_INVALIDATE;
> 110 }
> 111 } else if ((cmd->val & PCI_COMMAND_INVALIDATE) &&
> 112 !(value & PCI_COMMAND_INVALIDATE)) {
> 113 if (unlikely(verbose_request))
> 114 printk(KERN_DEBUG
> 115 DRV_NAME ": %s: disable memory-write-invalidate\n",
> 116 pci_name(dev));
> 117 pci_clear_mwi(dev);
> 118 }
> 119
> 120 if (dev_data && dev_data->allow_interrupt_control) {
> > 121 if ((cmd->val ^ val) & PCI_COMMAND_INTX_DISABLE) {
> 122 if (value & PCI_COMMAND_INTX_DISABLE) {
> 123 pci_intx(dev, 0);
> 124 } else {
> 125 /* Do not allow enabling INTx together with MSI or MSI-X. */
> 126 switch (xen_pcibk_get_interrupt_type(dev)) {
> 127 case INTERRUPT_TYPE_NONE:
> 128 case INTERRUPT_TYPE_INTX:
> 129 pci_intx(dev, 1);
> 130 break;
> 131 default:
> 132 return PCIBIOS_SET_FAILED;
> 133 }
> 134 }
> 135 }
> 136 }
> 137
> 138 cmd->val = value;
> 139
> 140 if (!xen_pcibk_permissive && (!dev_data || !dev_data->permissive))
> 141 return 0;
> 142
> 143 /* Only allow the guest to control certain bits. */
> 144 err = pci_read_config_word(dev, offset, &val);
> 145 if (err || val == value)
> 146 return err;
> 147
> 148 value &= PCI_COMMAND_GUEST;
> 149 value |= val & ~PCI_COMMAND_GUEST;
> 150
> 151 return pci_write_config_word(dev, offset, value);
> 152 }
> 153
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx Intel Corporation
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@xxxxxxxxxxxxxxxxx
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/202001112351.gy4c3aUU%25lkp%40intel.com.
--
Thanks,
~Nick Desaulniers