From 474ff41019068f6f7711ba7c4c867a082770cf3d Mon Sep 17 00:00:00 2001 From: Alexander Kudryavtsev Date: Wed, 7 Dec 2011 18:32:11 +0400 Subject: [PATCH 32/32] Fixed bug with spoiled MSI address and data cache --- palacios/src/devices/pci_msi_router.c | 2 +- palacios/src/devices/pci_passthrough.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/palacios/src/devices/pci_msi_router.c b/palacios/src/devices/pci_msi_router.c index 8521aef..d2e494e 100644 --- a/palacios/src/devices/pci_msi_router.c +++ b/palacios/src/devices/pci_msi_router.c @@ -143,7 +143,7 @@ int v3_msix_register_device(struct pci_device *dev, int msix_cap, void* table, v int tbl_size = mx->cap->control.tbl_size + 1, i; mx->vector_to_entry = V3_Malloc((MAX_IRQ > tbl_size ? MAX_IRQ : tbl_size) * sizeof(int)); V3_ASSERT(mx->vector_to_entry); - for(i = 0; i < tbl_size; ++i) { + for(i = 0; i < (MAX_IRQ > tbl_size ? MAX_IRQ : tbl_size); ++i) { mx->vector_to_entry[i] = -1; } diff --git a/palacios/src/devices/pci_passthrough.c b/palacios/src/devices/pci_passthrough.c index 75a3925..456aa77 100644 --- a/palacios/src/devices/pci_passthrough.c +++ b/palacios/src/devices/pci_passthrough.c @@ -988,8 +988,10 @@ static int cfg_msi_passthrough_capability_write(struct vm_device *dev, uint_t re union msi_control *c = state->msi.m.control; // copy guest data. it will be returned to guest when it reads. - state->msi.m.msg_data_orig = *data; - state->msi.m.msg_address_lo_orig = *address; + if(reg_num == MSI_CAP_DATA(msi_cap, c->is_64bit_cap)) + state->msi.m.msg_data_orig = *data; + if(reg_num == MSI_CAP_ADDR_LO(msi_cap)) + state->msi.m.msg_address_lo_orig = *address; if(c->enable && msi_passthrough_fix_guest_message(dev, address, data) != 0) return -1; if(v3_msi_capability_write(state->pci_dev, reg_num, length, state->msi.router_private) != 0) return -1; -- 1.7.5.4