Skip to contentSkip to conversation

xen-pcifront: Xen PCI frontend driver.

Xen-devel Dan Carpenter 2 participants 2 messages Jun 25, 2019

lore
Share & tools
lore
#0 lore raw

Hi Xen devs,

I get the following static checker warning:

	drivers/pci/xen-pcifront.c:107 schedule_pcifront_aer_op()
	warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64.

drivers/pci/xen-pcifront.c
105 static inline void schedule_pcifront_aer_op(struct pcifront_device *pdev) 106 {
107 if (test_bit(_XEN_PCIB_active, (unsigned long *)&pdev->sh_info->flags)

->flags is a u32 so this cast only works on little endian systems. I don't know if that matters at all. This driver has a bunch of similar issues. Is Xen x86 only? It's pretty normal for Intel code to rely on little endianness...

   108                  && !test_and_set_bit(_PDEVB_op_active, &pdev->flags)) {
   109                  dev_dbg(&pdev->xdev->dev, "schedule aer frontend job\n");
   110                  schedule_work(&pdev->op_work);

111 }
112 }

drivers/pci/xen-pcifront.c:107 schedule_pcifront_aer_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:129 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'set_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:142 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:150 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:162 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:670 pcifront_do_aer() warn: passing casted pointer '&pdev->sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/xen/mcelog.c:209 xen_mce_log() warn: passing casted pointer '&xen_mcelog.flags' to 'set_bit()' 32 vs 64. drivers/xen/privcmd.c:350 mmap_batch_fn() warn: passing casted pointer 'gfnp' to 'xen_remap_domain_gfn_array()' 64 vs 32. drivers/xen/privcmd.c:827 privcmd_ioctl_mmap_resource() warn: passing casted pointer 'pfns' to 'xen_remap_domain_mfn_array()' 64 vs 32. drivers/xen/xen-pciback/conf_space.c:172 xen_pcibk_config_read() warn: passing casted pointer '&value' to 'pci_read_config_word()' 32 vs 16. drivers/xen/xen-pciback/conf_space.c:57 conf_space_read() warn: passing casted pointer 'value' to 'field->u.w.read()' 32 vs 16. drivers/xen/xen-pciback/pciback_ops.c:310 xen_pcibk_test_and_schedule_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pciback_ops.c:316 xen_pcibk_test_and_schedule_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pciback_ops.c:396 xen_pcibk_do_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:731 common_process() warn: passing casted pointer '&sh_info->flags' to 'set_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:736 common_process() warn: passing casted pointer '&sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:741 common_process() warn: passing casted pointer '&sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:745 common_process() warn: passing casted pointer '&sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:753 common_process() warn: passing casted pointer '&sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:799 xen_pcibk_slot_reset() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:857 xen_pcibk_mmio_enabled() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:916 xen_pcibk_error_detected() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:969 xen_pcibk_error_resume() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64.

regards,
dan carpenter

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw
Quoted 8 lines · Dan Carpenter

Hi Xen devs,

I get the following static checker warning:

	drivers/pci/xen-pcifront.c:107 schedule_pcifront_aer_op()
	warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64.

drivers/pci/xen-pcifront.c

Quoted 8 lines
    105  static inline void schedule_pcifront_aer_op(struct pcifront_device *pdev)
    106  {
    107          if (test_bit(_XEN_PCIB_active, (unsigned long *)&pdev->sh_info->flags)

->flags is a u32 so this cast only works on little endian systems. I don't know if that matters at all. This driver has a bunch of similar issues. Is Xen x86 only? It's pretty normal for Intel code to rely on little endianness...

Xen is running on ARM, too. AFAIK it only supports little endian mode for guests, though.

Quoted 22 lines
    108                  && !test_and_set_bit(_PDEVB_op_active, &pdev->flags)) {
    109                  dev_dbg(&pdev->xdev->dev, "schedule aer frontend job\n");
    110                  schedule_work(&pdev->op_work);
    111          }
    112  }

drivers/pci/xen-pcifront.c:107 schedule_pcifront_aer_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:129 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'set_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:142 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:150 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:162 do_pci_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/pci/xen-pcifront.c:670 pcifront_do_aer() warn: passing casted pointer '&pdev->sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/xen/mcelog.c:209 xen_mce_log() warn: passing casted pointer '&xen_mcelog.flags' to 'set_bit()' 32 vs 64. drivers/xen/privcmd.c:350 mmap_batch_fn() warn: passing casted pointer 'gfnp' to 'xen_remap_domain_gfn_array()' 64 vs 32. drivers/xen/privcmd.c:827 privcmd_ioctl_mmap_resource() warn: passing casted pointer 'pfns' to 'xen_remap_domain_mfn_array()' 64 vs 32. drivers/xen/xen-pciback/conf_space.c:172 xen_pcibk_config_read() warn: passing casted pointer '&value' to 'pci_read_config_word()' 32 vs 16. drivers/xen/xen-pciback/conf_space.c:57 conf_space_read() warn: passing casted pointer 'value' to 'field->u.w.read()' 32 vs 16. drivers/xen/xen-pciback/pciback_ops.c:310 xen_pcibk_test_and_schedule_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pciback_ops.c:316 xen_pcibk_test_and_schedule_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pciback_ops.c:396 xen_pcibk_do_op() warn: passing casted pointer '&pdev->sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:731 common_process() warn: passing casted pointer '&sh_info->flags' to 'set_bit()' 32 vs 64.

Quoted 8 lines

drivers/xen/xen-pciback/pci_stub.c:736 common_process() warn: passing casted pointer '&sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:741 common_process() warn: passing casted pointer '&sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:745 common_process() warn: passing casted pointer '&sh_info->flags' to 'clear_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:753 common_process() warn: passing casted pointer '&sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:799 xen_pcibk_slot_reset() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:857 xen_pcibk_mmio_enabled() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:916 xen_pcibk_error_detected() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64. drivers/xen/xen-pciback/pci_stub.c:969 xen_pcibk_error_resume() warn: passing casted pointer '&psdev->pdev->sh_info->flags' to 'test_bit()' 32 vs 64.

The sh_info->flags accesses would need to be modified in order to fix the warnings. Either by adding *_bit32() variants to the kernel or by using atomic() accesses instead.

Patches welcome. :-)

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel