}
rc = vpci_msix_arch_enable_entry(entry, pdev,
- vmsix_table_base(pdev->vpci,
- VPCI_MSIX_TABLE));
+ vmsix_table_host_base(pdev->vpci,
+ VPCI_MSIX_TABLE));
if ( rc )
{
gprintk(XENLOG_WARNING, "%pp: unable to enable entry %u: %d\n",
addr = vmsix_table_size(vpci, VPCI_MSIX_TABLE);
fallthrough;
case VPCI_MSIX_TBL_HEAD:
- addr += vmsix_table_addr(vpci, VPCI_MSIX_TABLE);
+ addr += vmsix_table_host_addr(vpci, VPCI_MSIX_TABLE);
break;
case VPCI_MSIX_PBA_TAIL:
addr = vmsix_table_size(vpci, VPCI_MSIX_PBA);
fallthrough;
case VPCI_MSIX_PBA_HEAD:
- addr += vmsix_table_addr(vpci, VPCI_MSIX_PBA);
+ addr += vmsix_table_host_addr(vpci, VPCI_MSIX_PBA);
break;
default:
{
unsigned long pfn = PFN_DOWN(addr);
- /*
- * The logic below relies on having the tables identity mapped to the guest
- * address space, or for the `addr` parameter to be translated into its
- * host physical memory address equivalent.
- */
-
if ( pfn == PFN_DOWN(vmsix_table_addr(vpci, VPCI_MSIX_TABLE)) )
return VPCI_MSIX_TBL_HEAD;
if ( pfn == PFN_DOWN(vmsix_table_addr(vpci, VPCI_MSIX_TABLE) +
* Helper functions to fetch MSIX related data. They are used by both the
* emulated MSIX code and the BAR handlers.
*/
+static inline paddr_t vmsix_table_host_base(const struct vpci *vpci,
+ unsigned int nr)
+{
+ return vpci->header.bars[vpci->msix->tables[nr] & PCI_MSIX_BIRMASK].addr;
+}
+
+static inline paddr_t vmsix_table_host_addr(const struct vpci *vpci,
+ unsigned int nr)
+{
+ return vmsix_table_host_base(vpci, nr) +
+ (vpci->msix->tables[nr] & ~PCI_MSIX_BIRMASK);
+}
+
static inline paddr_t vmsix_table_base(const struct vpci *vpci, unsigned int nr)
{
return vpci->header.bars[vpci->msix->tables[nr] &