On Fri, Aug 27, 2021 at 01:53:27PM -0400, Jagannathan Raman wrote: > +/** > + * VFU_OBJECT_BAR_HANDLER - macro for defining handlers for PCI BARs. > + * > + * To create handler for BAR number 2, VFU_OBJECT_BAR_HANDLER(2) would > + * define vfu_object_bar2_handler > + */ > +#define VFU_OBJECT_BAR_HANDLER(BAR_NO) \ > + static ssize_t vfu_object_bar##BAR_NO##_handler(vfu_ctx_t *vfu_ctx, \ > + char * const buf, size_t count, \ > + loff_t offset, const bool is_write) \ > + { \ > + VfuObject *o = vfu_get_private(vfu_ctx); \ > + hwaddr addr = (hwaddr)(pci_get_long(o->pci_dev->config + \ > + PCI_BASE_ADDRESS_0 + \ > + (4 * BAR_NO)) + offset); \ Does this handle 64-bit BARs? > +/** > + * vfu_object_register_bars - Identify active BAR regions of pdev and setup > + * callbacks to handle read/write accesses > + */ > +static void vfu_object_register_bars(vfu_ctx_t *vfu_ctx, PCIDevice *pdev) > +{ > + uint32_t orig_val, new_val; > + int i, size; > + > + for (i = 0; i < PCI_NUM_REGIONS; i++) { > + orig_val = pci_default_read_config(pdev, > + PCI_BASE_ADDRESS_0 + (4 * i), 4); Same question as in an earlier patch: should we call pdev->read_config()?