msix: couple fixes
cover msix: couple fixes
I've been porting the qemu vfio driver to use the common msix infrastructure and hit a couple issues. The first patch addresses the problem that a device may already have MSI-X capability setup and non-adjustable BARs, so msix_init should be able to use the existing capability instead of adding it's own.
I'm surprised we need the second patch, as I'm not sure how things work today without it. We allocate msix_irq_entries within a KVM_CAP_IRQCHIP #ifdef. This should be pulled in from kvm.h, if we have CONFIG_KVM, but that's pulled in from config-target.h, which we don't include. We can add config.h to msix.c, but that only works if the msix object is in Makefile.target instead of Makefile.objs. Feel free to fix this differently, but I think something is wrong there. Thanks,
Alex
---
Alex Williamson (2):
msix: Pull in config.h for CONFIG_KVM
msix: Allow msix_init on a device with existing MSI-X capability
Makefile.objs | 2 -- Makefile.target | 1 + hw/msix.c | 68 ++++++++++++++++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 31 deletions(-)
PATCH 1/2 msix: Allow msix_init on a device with existing MSI-X capability
To enable common msix support to be used with pass through devices, don't attempt to change the BAR if the device already has an MSI-X capability. This also means we want to pay closer attention to the size when we map the msix table page, as it isn't necessarily covering the entire end of the BAR.
---
hw/msix.c | 67 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)
hw/msix.c +38 -29
@@ -167,35 +167,43 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries, {int config_offset;uint8_t *config; -uint32_t new_size; -if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) -return -EINVAL ; -if (bar_size >0x80000000 ) -return -ENOSPC ; - -/* Add space for MSI-X structures */ -if (!bar_size) { - new_size =MSIX_PAGE_SIZE ; - }else if (bar_size <MSIX_PAGE_SIZE ) { - bar_size =MSIX_PAGE_SIZE ; - new_size =MSIX_PAGE_SIZE *2 ; - }else { - new_size = bar_size *2 ; - } - - pdev->msix_bar_size = new_size; - config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX ,MSIX_CAP_LENGTH ); -if (config_offset <0 ) -return config_offset; - config = pdev->config + config_offset; - -pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); -/* Table on top of BAR */ -pci_set_long (config +MSIX_TABLE_OFFSET , bar_size | bar_nr); -/* Pending bits on top of that */ -pci_set_long (config +MSIX_PBA_OFFSET , (bar_size +MSIX_PAGE_PENDING ) | - bar_nr); + pdev->msix_bar_size = bar_size; + + config_offset =pci_find_capability (pdev,PCI_CAP_ID_MSIX ); + +if (!config_offset) { +uint32_t new_size; + +if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) +return -EINVAL ; +if (bar_size >0x80000000 ) +return -ENOSPC ; + +/* Add space for MSI-X structures */ +if (!bar_size) { + new_size =MSIX_PAGE_SIZE ; + }else if (bar_size <MSIX_PAGE_SIZE ) { + bar_size =MSIX_PAGE_SIZE ; + new_size =MSIX_PAGE_SIZE *2 ; + }else { + new_size = bar_size *2 ; + } + + pdev->msix_bar_size = new_size; + config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX , +MSIX_CAP_LENGTH ); +if (config_offset <0 ) +return config_offset; + config = pdev->config + config_offset; + +pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); +/* Table on top of BAR */ +pci_set_long (config +MSIX_TABLE_OFFSET , bar_size | bar_nr); +/* Pending bits on top of that */ +pci_set_long (config +MSIX_PBA_OFFSET , (bar_size +MSIX_PAGE_PENDING ) | + bar_nr); + } pdev->msix_cap = config_offset;/* Make flags bit writeable. */ pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
@@ -337,7 +345,8 @@ void msix_mmio_map(PCIDevice *d, int region_num,return ;if (size <= offset)return ; -cpu_register_physical_memory (addr + offset, size - offset, +cpu_register_physical_memory (addr + offset, +MIN (size - offset,MSIX_PAGE_SIZE ), d->msix_mmio_index); }
Re: [PATCH 1/2] msix: Allow msix_init on a device with existing MSI-X capability
Quoted 89 lines · Alex Williamson
To enable common msix support to be used with pass through devices, don't attempt to change the BAR if the device already has an MSI-X capability. This also means we want to pay closer attention to the size when we map the msix table page, as it isn't necessarily covering the entire end of the BAR.
Signed-off-by Alex Williamson <[email protected]>---
hw/msix.c | 67 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)hw/msix.c +36
-28@@ -167,35 +167,43 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries, {int config_offset;uint8_t *config; -uint32_t new_size; -if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) -return -EINVAL ; -if (bar_size >0x80000000 ) -return -ENOSPC ; - -/* Add space for MSI-X structures */ -if (!bar_size) { - new_size =MSIX_PAGE_SIZE ; - }else if (bar_size <MSIX_PAGE_SIZE ) { - bar_size =MSIX_PAGE_SIZE ; - new_size =MSIX_PAGE_SIZE *2 ; - }else { - new_size = bar_size *2 ; - } - - pdev->msix_bar_size = new_size; - config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX ,MSIX_CAP_LENGTH ); -if (config_offset <0 ) -return config_offset; - config = pdev->config + config_offset; - -pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); -/* Table on top of BAR */ -pci_set_long (config +MSIX_TABLE_OFFSET , bar_size | bar_nr); -/* Pending bits on top of that */ -pci_set_long (config +MSIX_PBA_OFFSET , (bar_size +MSIX_PAGE_PENDING ) | - bar_nr); + pdev->msix_bar_size = bar_size; + + config_offset =pci_find_capability (pdev,PCI_CAP_ID_MSIX ); + +if (!config_offset) { +uint32_t new_size; + +if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) +return -EINVAL ; +if (bar_size >0x80000000 ) +return -ENOSPC ; + +/* Add space for MSI-X structures */ +if (!bar_size) { + new_size =MSIX_PAGE_SIZE ; + }else if (bar_size <MSIX_PAGE_SIZE ) { + bar_size =MSIX_PAGE_SIZE ; + new_size =MSIX_PAGE_SIZE *2 ; + }else { + new_size = bar_size *2 ; + } + + pdev->msix_bar_size = new_size; + config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX , +MSIX_CAP_LENGTH ); +if (config_offset <0 ) +return config_offset; + config = pdev->config + config_offset; + +pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); +/* Table on top of BAR */ +pci_set_long (config +MSIX_TABLE_OFFSET , bar_size | bar_nr); +/* Pending bits on top of that */ +pci_set_long (config +MSIX_PBA_OFFSET , (bar_size +MSIX_PAGE_PENDING ) | + bar_nr); + } pdev->msix_cap = config_offset;/* Make flags bit writeable. */ pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
hw/msix.c void msix_mmio_map(PCIDevice *d, int region_num, · line 349
Quoted 6 lines
hw/msix.c +2
-1@@ -337,7 +345,8 @@ void msix_mmio_map(PCIDevice *d, int region_num,return ;if (size <= offset)return ; - cpu_register_physical_memory(addr + offset, size - offset, + cpu_register_physical_memory(addr + offset, + MIN(size - offset, MSIX_PAGE_SIZE),
This is wrong I think, the table might not fit in a single page. You would need to read table size out of from device config.
Quoted 3 lines
hw/msix.c +0
-0d->msix_mmio_index); }
Re: [PATCH 1/2] msix: Allow msix_init on a device with existing MSI-X capability
Quoted 91 lines · Michael S. Tsirkin
Quoted 90 lines · Alex Williamson
To enable common msix support to be used with pass through devices, don't attempt to change the BAR if the device already has an MSI-X capability. This also means we want to pay closer attention to the size when we map the msix table page, as it isn't necessarily covering the entire end of the BAR.
Signed-off-by Alex Williamson <[email protected]>---
hw/msix.c | 67 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)hw/msix.c +36
-28@@ -167,35 +167,43 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries, {int config_offset;uint8_t *config; -uint32_t new_size; -if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) -return -EINVAL ; -if (bar_size >0x80000000 ) -return -ENOSPC ; - -/* Add space for MSI-X structures */ -if (!bar_size) { - new_size =MSIX_PAGE_SIZE ; - }else if (bar_size <MSIX_PAGE_SIZE ) { - bar_size =MSIX_PAGE_SIZE ; - new_size =MSIX_PAGE_SIZE *2 ; - }else { - new_size = bar_size *2 ; - } - - pdev->msix_bar_size = new_size; - config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX ,MSIX_CAP_LENGTH ); -if (config_offset <0 ) -return config_offset; - config = pdev->config + config_offset; - -pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); -/* Table on top of BAR */ -pci_set_long (config +MSIX_TABLE_OFFSET , bar_size | bar_nr); -/* Pending bits on top of that */ -pci_set_long (config +MSIX_PBA_OFFSET , (bar_size +MSIX_PAGE_PENDING ) | - bar_nr); + pdev->msix_bar_size = bar_size; + + config_offset =pci_find_capability (pdev,PCI_CAP_ID_MSIX ); + +if (!config_offset) { +uint32_t new_size; + +if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) +return -EINVAL ; +if (bar_size >0x80000000 ) +return -ENOSPC ; + +/* Add space for MSI-X structures */ +if (!bar_size) { + new_size =MSIX_PAGE_SIZE ; + }else if (bar_size <MSIX_PAGE_SIZE ) { + bar_size =MSIX_PAGE_SIZE ; + new_size =MSIX_PAGE_SIZE *2 ; + }else { + new_size = bar_size *2 ; + } + + pdev->msix_bar_size = new_size; + config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX , +MSIX_CAP_LENGTH ); +if (config_offset <0 ) +return config_offset; + config = pdev->config + config_offset; + +pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); +/* Table on top of BAR */ +pci_set_long (config +MSIX_TABLE_OFFSET , bar_size | bar_nr); +/* Pending bits on top of that */ +pci_set_long (config +MSIX_PBA_OFFSET , (bar_size +MSIX_PAGE_PENDING ) | + bar_nr); + } pdev->msix_cap = config_offset;/* Make flags bit writeable. */ pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |@@ -337,7 +345,8 @@ void msix_mmio_map(PCIDevice *d, int region_num,return ;
Quoted 8 lines
hw/msix.c void msix_mmio_map(PCIDevice *d, int region_num, · line 349
Quoted 5 lines
hw/msix.c +2
-1if (size <= offset)return ; - cpu_register_physical_memory(addr + offset, size - offset, + cpu_register_physical_memory(addr + offset, + MIN(size - offset, MSIX_PAGE_SIZE),This is wrong I think, the table might not fit in a single page. You would need to read table size out of from device config.
That's true, but I was hoping to save that for later since we don't seem to be running into that problem yet. Current device assignment code assumes a single page, and I haven't heard of anyone with a vector table that exceeds that yet. Thanks,
Alex
Re: [PATCH 1/2] msix: Allow msix_init on a device with existing MSI-X capability
Quoted 98 lines · Alex Williamson
Quoted 97 lines · Michael S. Tsirkin
Quoted 95 lines · Alex Williamson
To enable common msix support to be used with pass through devices, don't attempt to change the BAR if the device already has an MSI-X capability. This also means we want to pay closer attention to the size when we map the msix table page, as it isn't necessarily covering the entire end of the BAR.
Signed-off-by Alex Williamson<[email protected]>---
hw/msix.c | 67 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)diff --git
a/hw/msix.cb/hw/msix.c
index 43efbd2..4122395 100644
---a/hw/msix.c
+++b/hw/msix.c
@@ -167,35 +167,43 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,{ int config_offset; uint8_t *config;-
uint32_tnew_size;- if (nentries< 1 || nentries>
PCI_MSIX_FLAGS_QSIZE+ 1)
- return-EINVAL;
- if (bar_size>0x80000000)
- return-ENOSPC;
-
- /* Add space for MSI-X structures */
- if (!bar_size) {
-new_size=MSIX_PAGE_SIZE;
- } else if (bar_size<MSIX_PAGE_SIZE) {
-bar_size=MSIX_PAGE_SIZE;
-new_size=MSIX_PAGE_SIZE* 2;
- } else {
-new_size=bar_size* 2;
- }
-- pdev->msix_bar_size = new_size; - config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX, MSIX_CAP_LENGTH); - if (config_offset< 0) - return config_offset; - config = pdev->config + config_offset; - - pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1); - /* Table on top of BAR */ - pci_set_long(config + MSIX_TABLE_OFFSET, bar_size | bar_nr); - /* Pending bits on top of that */ - pci_set_long(config + MSIX_PBA_OFFSET, (bar_size + MSIX_PAGE_PENDING) | - bar_nr); + pdev->msix_bar_size = bar_size; + + config_offset = pci_find_capability(pdev, PCI_CAP_ID_MSIX); + + if (!config_offset) { + uint32_t new_size; + + if (nentries< 1 || nentries> PCI_MSIX_FLAGS_QSIZE + 1) + return -EINVAL; + if (bar_size> 0x80000000) + return -ENOSPC; + + /* Add space for MSI-X structures */ + if (!bar_size) { + new_size = MSIX_PAGE_SIZE; + } else if (bar_size< MSIX_PAGE_SIZE) { + bar_size = MSIX_PAGE_SIZE; + new_size = MSIX_PAGE_SIZE * 2; + } else { + new_size = bar_size * 2; + } + + pdev->msix_bar_size = new_size; + config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX, + MSIX_CAP_LENGTH); + if (config_offset< 0) + return config_offset; + config = pdev->config + config_offset; + + pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1); + /* Table on top of BAR */ + pci_set_long(config + MSIX_TABLE_OFFSET, bar_size | bar_nr); + /* Pending bits on top of that */ + pci_set_long(config + MSIX_PBA_OFFSET, (bar_size + MSIX_PAGE_PENDING) | + bar_nr); + } pdev->msix_cap = config_offset; /* Make flags bit writeable. */ pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK | @@ -337,7 +345,8 @@ void msix_mmio_map(PCIDevice *d, int region_num, return; if (size<= offset) return;- cpu_register_physical_memory(addr + offset, size - offset,
+ cpu_register_physical_memory(addr + offset,
+MIN(size - offset, MSIX_PAGE_SIZE),
Quoted 8 lines
Quoted 2 lines
This is wrong I think, the table might not fit in a single page. You would need to read table size out of from device config.
That's true, but I was hoping to save that for later since we don't seem to be running into that problem yet. Current device assignment code assumes a single page, and I haven't heard of anyone with a vector table that exceeds that yet. Thanks,
Ok; applied. Please add some warning if the condition happens so the breakage is at least not silent.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 1/2] msix: Allow msix_init on a device with existing MSI-X capability
Quoted 102 lines · Avi Kivity
Quoted 101 lines · Alex Williamson
Quoted 99 lines · Michael S. Tsirkin
Quoted 92 lines · Alex Williamson
To enable common msix support to be used with pass through devices, don't attempt to change the BAR if the device already has an MSI-X capability. This also means we want to pay closer attention to the size when we map the msix table page, as it isn't necessarily covering the entire end of the BAR.
Signed-off-by Alex Williamson<[email protected]>---
hw/msix.c | 67 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 38 insertions(+), 29 deletions(-)diff --git
a/hw/msix.cb/hw/msix.c
index 43efbd2..4122395 100644
---a/hw/msix.c
+++b/hw/msix.c
@@ -167,35 +167,43 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,{ int config_offset; uint8_t *config;-
uint32_tnew_size;- if (nentries< 1 || nentries>
PCI_MSIX_FLAGS_QSIZE+ 1)
- return-EINVAL;
- if (bar_size>0x80000000)
- return-ENOSPC;
-
- /* Add space for MSI-X structures */
- if (!bar_size) {
-new_size=MSIX_PAGE_SIZE;
- } else if (bar_size<MSIX_PAGE_SIZE) {
-bar_size=MSIX_PAGE_SIZE;
-new_size=MSIX_PAGE_SIZE* 2;
- } else {
-new_size=bar_size* 2;
- }
-- pdev->msix_bar_size = new_size; - config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX, MSIX_CAP_LENGTH); - if (config_offset< 0) - return config_offset; - config = pdev->config + config_offset; - - pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1); - /* Table on top of BAR */ - pci_set_long(config + MSIX_TABLE_OFFSET, bar_size | bar_nr); - /* Pending bits on top of that */ - pci_set_long(config + MSIX_PBA_OFFSET, (bar_size + MSIX_PAGE_PENDING) | - bar_nr); + pdev->msix_bar_size = bar_size; + + config_offset = pci_find_capability(pdev, PCI_CAP_ID_MSIX); + + if (!config_offset) { + uint32_t new_size; + + if (nentries< 1 || nentries> PCI_MSIX_FLAGS_QSIZE + 1) + return -EINVAL; + if (bar_size> 0x80000000) + return -ENOSPC; + + /* Add space for MSI-X structures */ + if (!bar_size) { + new_size = MSIX_PAGE_SIZE; + } else if (bar_size< MSIX_PAGE_SIZE) { + bar_size = MSIX_PAGE_SIZE; + new_size = MSIX_PAGE_SIZE * 2; + } else { + new_size = bar_size * 2; + } + + pdev->msix_bar_size = new_size; + config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX, + MSIX_CAP_LENGTH); + if (config_offset< 0) + return config_offset; + config = pdev->config + config_offset; + + pci_set_word(config + PCI_MSIX_FLAGS, nentries - 1); + /* Table on top of BAR */ + pci_set_long(config + MSIX_TABLE_OFFSET, bar_size | bar_nr); + /* Pending bits on top of that */ + pci_set_long(config + MSIX_PBA_OFFSET, (bar_size + MSIX_PAGE_PENDING) | + bar_nr); + } pdev->msix_cap = config_offset; /* Make flags bit writeable. */ pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK | @@ -337,7 +345,8 @@ void msix_mmio_map(PCIDevice *d, int region_num, return; if (size<= offset) return;Quoted 3 lines
- cpu_register_physical_memory(addr + offset, size - offset,
+ cpu_register_physical_memory(addr + offset,
+MIN(size - offset, MSIX_PAGE_SIZE),This is wrong I think, the table might not fit in a single page. You would need to read table size out of from device config.
Quoted 8 lines
Quoted 5 lines
That's true, but I was hoping to save that for later since we don't seem to be running into that problem yet. Current device assignment code assumes a single page, and I haven't heard of anyone with a vector table that exceeds that yet. Thanks,
Ok; applied. Please add some warning if the condition happens so the breakage is at least not silent.
Looks like this is already handled before we even get here. msix_init() checks nentries against the max supported in a single page and returns -EINVAL if over. So I think we're safely covered until we add support for more pages. Thanks,
Alex
PATCH 2/2 msix: Pull in config.h for CONFIG_KVM
In reply to Alex WilliamsonWe need to pull in config.h or else kvm.h doesn't pull in linux/config.h, which we need if we ever want KVM_CAP_IRQCHIP defined. This requires moving the object over to Makefile.target or else we can't find config-target.h
---
Makefile.objs | 2 -- Makefile.target | 1 + hw/msix.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
Makefile.objs +0 -2
@@ -201,8 +201,6 @@ hw-obj-$(CONFIG_PIIX4) += piix4.o # PCI watchdog devices hw-obj-y += wdt_i6300esb.o -hw-obj-y += msix.o - # PCI network cards hw-obj-y += ne2000.o hw-obj-y += eepro100.o
Makefile.target +1 -0
@@ -185,6 +185,7 @@ obj-y += rwhandler.o obj-$(CONFIG_KVM) += kvm.o kvm-all.o obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-y += memory.o +obj-y += msix.o LIBS+=-lz
hw/msix.c +1 -0
@@ -11,6 +11,7 @@* the COPYING file in the top-level directory. */ +#include "config.h" #include "hw.h" #include "msix.h" #include "pci.h"
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 31 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>---
Makefile.objs | 2 -- Makefile.target | 1 + hw/msix.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)Makefile.objs +0
-2@@ -201,8 +201,6 @@ hw-obj-$(CONFIG_PIIX4) += piix4.o # PCI watchdog devices hw-obj-y += wdt_i6300esb.o -hw-obj-y += msix.o - # PCI network cards hw-obj-y += ne2000.o hw-obj-y += eepro100.oMakefile.target +0
-0
Makefile.target obj-y += rwhandler.o · line 188
Quoted 4 lines
Makefile.target +1
-0@@ -185,6 +185,7 @@ obj-y += rwhandler.o obj-$(CONFIG_KVM) += kvm.o kvm-all.o obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-y += memory.o +obj-y += msix.o
Oops, memory.c isn't upstream, I'll push it down in my patch queue and send a new one.
Alex
Quoted 15 lines
Makefile.target +0
-0LIBS+=-lzhw/msix.c +1
-0@@ -11,6 +11,7 @@* the COPYING file in the top-level directory. */ +#include "config.h" #include "hw.h" #include "msix.h" #include "pci.h"
Paolo Bonzini
maintainerRe: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 2 lines · Alex Williamson
Oops,
memory.cisn't upstream, I'll push it down in my patch queue and send a new one.
Neither is kvm_set_irq actually. :) This patch is only needed for qemu-kvm.
BTW, maybe the better solution would be to move the kvm_*_irq* functions from qemu-kvm.c to kvm-all.c, add stubs to kvm-stub.c, and get rid of the #ifdef completely in msix.c
Paolo
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
In reply to Alex WilliamsonQuoted 6 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>
Why? We just moved it from .target to .objs, see889e30cc18e21f2091b77267dca8096d7dd34f8b.
Quoted 44 lines
---
Makefile.objs | 2 -- Makefile.target | 1 + hw/msix.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)Makefile.objs +0
-2@@ -201,8 +201,6 @@ hw-obj-$(CONFIG_PIIX4) += piix4.o # PCI watchdog devices hw-obj-y += wdt_i6300esb.o -hw-obj-y += msix.o - # PCI network cards hw-obj-y += ne2000.o hw-obj-y += eepro100.oMakefile.target +1
-0@@ -185,6 +185,7 @@ obj-y += rwhandler.o obj-$(CONFIG_KVM) += kvm.o kvm-all.o obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-y += memory.o +obj-y += msix.o LIBS+=-lzhw/msix.c +1
-0@@ -11,6 +11,7 @@* the COPYING file in the top-level directory. */ +#include "config.h" #include "hw.h" #include "msix.h" #include "pci.h"
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>Why? We just moved it from .target to .objs, see
889e30cc18e21f2091b77267dca8096d7dd34f8b.
Maybe that's why it used to work. When building in the qemu-kvm.git tree, I'm not getting CONFIG_KVM defined, which means I'm not getting KVM_CAP_IRQCHIP defined, which results in msix_irq_entries not being allocated. Then when I call msix_vector_use, I get a seg fault. Something is broken there. Thanks,
Alex
Quoted 44 lines
Quoted 44 lines
---
Makefile.objs | 2 -- Makefile.target | 1 + hw/msix.c | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)Makefile.objs +0
-2@@ -201,8 +201,6 @@ hw-obj-$(CONFIG_PIIX4) += piix4.o # PCI watchdog devices hw-obj-y += wdt_i6300esb.o -hw-obj-y += msix.o - # PCI network cards hw-obj-y += ne2000.o hw-obj-y += eepro100.oMakefile.target +1
-0@@ -185,6 +185,7 @@ obj-y += rwhandler.o obj-$(CONFIG_KVM) += kvm.o kvm-all.o obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-y += memory.o +obj-y += msix.o LIBS+=-lzhw/msix.c +1
-0@@ -11,6 +11,7 @@* the COPYING file in the top-level directory. */ +#include "config.h" #include "hw.h" #include "msix.h" #include "pci.h"
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 12 lines · Alex Williamson
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>Why? We just moved it from .target to .objs, see
889e30cc18e21f2091b77267dca8096d7dd34f8b.
Quoted 7 lines
Maybe that's why it used to work. When building in the qemu-kvm.git tree, I'm not getting
CONFIG_KVMdefined, which means I'm not gettingKVM_CAP_IRQCHIPdefined, which results inmsix_irq_entriesnot being allocated. Then when I callmsix_vector_use, I get a seg fault. Something is broken there. Thanks,Alex
This is hopefully fixed in the latest bits.bd8b215bce453706c3951460cc7e6627ccb90314
Signature · 1 line
MST
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Alex Williamson
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>Why? We just moved it from .target to .objs, see
889e30cc18e21f2091b77267dca8096d7dd34f8b.Maybe that's why it used to work. When building in the qemu-kvm.git tree, I'm not getting
CONFIG_KVMdefined, which means I'm not gettingKVM_CAP_IRQCHIPdefined, which results inmsix_irq_entriesnot being allocated. Then when I callmsix_vector_use, I get a seg fault. Something is broken there. Thanks,
Quoted 4 lines
Quoted 1 line
Alex
This is hopefully fixed in the latest bits.
bd8b215bce453706c3951460cc7e6627ccb90314
Nope, my tree includes that. It's not kvm_set_irq, it's kvm_msix_add, which dereferences msix_irq_entries, which is only allocated in msix_init if KVM_CAP_IRQCHIP is defined, which it's not. Maybe you also meant to remove the ifdef from msix_init? I also note there's another in msix_notify. Thanks,
Alex
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 25 lines · Alex Williamson
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Alex Williamson
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>Why? We just moved it from .target to .objs, see
889e30cc18e21f2091b77267dca8096d7dd34f8b.Maybe that's why it used to work. When building in the qemu-kvm.git tree, I'm not getting
CONFIG_KVMdefined, which means I'm not gettingKVM_CAP_IRQCHIPdefined, which results inmsix_irq_entriesnot being allocated. Then when I callmsix_vector_use, I get a seg fault. Something is broken there. Thanks,Quoted 4 lines
Quoted 1 line
Alex
This is hopefully fixed in the latest bits.
bd8b215bce453706c3951460cc7e6627ccb90314
Quoted 7 lines
Nope, my tree includes that. It's not
kvm_set_irq, it'skvm_msix_add, which dereferencesmsix_irq_entries, which is only allocated inmsix_initifKVM_CAP_IRQCHIPis defined, which it's not. Maybe you also meant to remove the ifdef frommsix_init? I also note there's another inmsix_notify. Thanks,Alex
Not sure what's wrong:
$git grep KVM_CAP_IRQCHIP origin/master -- hw/msix.c $
http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/msix.c;hb=HEAD
also does not show any ifdefs.
Signature · 1 line
MST
Re: [PATCH 2/2] msix: Pull in config.h for CONFIG_KVM
Quoted 34 lines · Michael S. Tsirkin
Quoted 25 lines · Alex Williamson
Quoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Alex Williamson
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Alex Williamson
We need to pull in
config.hor elsekvm.hdoesn't pull inlinux/config.h, which we need if we ever wantKVM_CAP_IRQCHIPdefined. This requires moving the object over to Makefile.target or else we can't findconfig-target.hSigned-off-by Alex Williamson <[email protected]>Why? We just moved it from .target to .objs, see
889e30cc18e21f2091b77267dca8096d7dd34f8b.Maybe that's why it used to work. When building in the qemu-kvm.git tree, I'm not getting
CONFIG_KVMdefined, which means I'm not gettingKVM_CAP_IRQCHIPdefined, which results inmsix_irq_entriesnot being allocated. Then when I callmsix_vector_use, I get a seg fault. Something is broken there. Thanks,Quoted 4 lines
Quoted 1 line
Alex
This is hopefully fixed in the latest bits.
bd8b215bce453706c3951460cc7e6627ccb90314Quoted 7 lines
Nope, my tree includes that. It's not
kvm_set_irq, it'skvm_msix_add, which dereferencesmsix_irq_entries, which is only allocated inmsix_initifKVM_CAP_IRQCHIPis defined, which it's not. Maybe you also meant to remove the ifdef frommsix_init? I also note there's another inmsix_notify. Thanks,Alex
Quoted 7 lines
Not sure what's wrong:
$git grepKVM_CAP_IRQCHIPorigin/master --hw/msix.c$http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=blob;f=hw/msix.c;hb=HEAD
also does not show any ifdefs.
Hmm, somehow my tree missed 763a04a920f1098e57ad6b46c91c3e531adc961d Ignore this patch and I'll refresh again. Sorry for the noise.
Alex