From 93ee96c2799570448c7c90ee272b5113d1384df2 Mon Sep 17 00:00:00 2001 From: Alexander Kudryavtsev Date: Wed, 7 Dec 2011 14:37:47 +0400 Subject: [PATCH 29/32] Added MSI-X BAR update for 32-bit BARs --- palacios/src/devices/pci_passthrough.c | 39 +++++++++++++++++++++---------- 1 files changed, 26 insertions(+), 13 deletions(-) diff --git a/palacios/src/devices/pci_passthrough.c b/palacios/src/devices/pci_passthrough.c index 99b0798..3946b3f 100644 --- a/palacios/src/devices/pci_passthrough.c +++ b/palacios/src/devices/pci_passthrough.c @@ -632,15 +632,22 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { } } else if (vbar->type == PT_BAR_MEM32) { // remove old mapping - struct v3_mem_region * old_reg = v3_get_mem_region(dev->vm, V3_MEM_CORE_ANY, vbar->addr); - if (old_reg == NULL) { - // uh oh... - PrintError("Could not find PCI Passthrough memory redirection region (addr=0x%x)\n", (uint32_t)vbar->addr); - return -1; - } + if(vbar->flags.msix) { + if(msix_unset_bar_hooks(dev, bar_num, state->msi.mx.cap->tbl_offset << 3, + (state->msi.mx.cap->control.tbl_size + 1) * sizeof(struct msix_tbl_entry)) != 0) return -1; + } else { - v3_delete_mem_region(dev->vm, old_reg); + struct v3_mem_region * old_reg = v3_get_mem_region(dev->vm, V3_MEM_CORE_ANY, vbar->addr); + + if (old_reg == NULL) { + // uh oh... + PrintError("Could not find PCI Passthrough memory redirection region (addr=0x%x)\n", (uint32_t)vbar->addr); + return -1; + } + + v3_delete_mem_region(dev->vm, old_reg); + } // clear the low bits to match the size *src &= ~(pbar->size - 1); @@ -652,13 +659,19 @@ static int pci_bar_write(int bar_num, uint32_t * src, void * private_data) { vbar->addr = PCI_MEM32_BASE(*src); - PrintDebug("Adding pci Passthrough remapping: start=0x%x, size=%d, end=0x%x\n", - (uint32_t)vbar->addr, vbar->size, (uint32_t)vbar->addr + vbar->size); + if(vbar->flags.msix) { + if(msix_set_bar_hooks(dev, bar_num, state->msi.mx.cap->tbl_offset << 3, + (state->msi.mx.cap->control.tbl_size + 1) * sizeof(struct msix_tbl_entry)) != 0) + return -1; + } else { + PrintDebug("Adding pci Passthrough remapping: start=0x%x, size=%d, end=0x%x\n", + (uint32_t)vbar->addr, vbar->size, (uint32_t)vbar->addr + vbar->size); - v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, - vbar->addr, - vbar->addr + vbar->size - 1, - pbar->addr); + v3_add_shadow_mem(dev->vm, V3_MEM_CORE_ANY, + vbar->addr, + vbar->addr + vbar->size - 1, + pbar->addr); + } } else if (vbar->type == PT_BAR_MEM64_LO) { // We only store the written values here, the actual reconfig comes when the high BAR is updated -- 1.7.5.4