public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it
@ 2011-08-02 12:27 Jan Kiszka
  2011-08-02 17:02 ` Alex Williamson
  2011-08-03 20:29 ` Marcelo Tosatti
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Kiszka @ 2011-08-02 12:27 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Alex Williamson

Add checks for KVM_CAP_ASSIGN_DEV_IRQ (MSI) and KVM_CAP_DEVICE_MSIX, do
not set up MSI/MSI-X if the required kernel features are missing.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/device-assignment.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 4cc7b1a..7e965cb 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1201,7 +1201,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
 
     /* Expose MSI capability
      * MSI capability is the 1st capability in capability config */
-    if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0))) {
+    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
+    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
         dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
         /* Only 32-bit/no-mask currently supported */
         if ((ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10)) < 0) {
@@ -1222,7 +1223,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
         pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff);
     }
     /* Expose MSI-X capability */
-    if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0))) {
+    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);
+    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_DEVICE_MSIX)) {
         int bar_nr;
         uint32_t msix_table_entry;
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it
  2011-08-02 12:27 [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it Jan Kiszka
@ 2011-08-02 17:02 ` Alex Williamson
  2011-08-02 17:32   ` Jan Kiszka
  2011-08-03 20:29 ` Marcelo Tosatti
  1 sibling, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2011-08-02 17:02 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm

On Tue, 2011-08-02 at 14:27 +0200, Jan Kiszka wrote:
> Add checks for KVM_CAP_ASSIGN_DEV_IRQ (MSI) and KVM_CAP_DEVICE_MSIX, do
> not set up MSI/MSI-X if the required kernel features are missing.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/device-assignment.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 4cc7b1a..7e965cb 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -1201,7 +1201,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>  
>      /* Expose MSI capability
>       * MSI capability is the 1st capability in capability config */
> -    if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0))) {
> +    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
> +    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {

Is it even useful to have a device assigned w/o KVM_CAP_ASSIGN_DEV_IRQ?
Thanks,

Alex

>          dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
>          /* Only 32-bit/no-mask currently supported */
>          if ((ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10)) < 0) {
> @@ -1222,7 +1223,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>          pci_set_word(pci_dev->wmask + pos + PCI_MSI_DATA_32, 0xffff);
>      }
>      /* Expose MSI-X capability */
> -    if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0))) {
> +    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSIX, 0);
> +    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_DEVICE_MSIX)) {
>          int bar_nr;
>          uint32_t msix_table_entry;
>  




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it
  2011-08-02 17:02 ` Alex Williamson
@ 2011-08-02 17:32   ` Jan Kiszka
  2011-08-02 20:26     ` Alex Williamson
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2011-08-02 17:32 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Avi Kivity, Marcelo Tosatti, kvm

On 2011-08-02 19:02, Alex Williamson wrote:
> On Tue, 2011-08-02 at 14:27 +0200, Jan Kiszka wrote:
>> Add checks for KVM_CAP_ASSIGN_DEV_IRQ (MSI) and KVM_CAP_DEVICE_MSIX, do
>> not set up MSI/MSI-X if the required kernel features are missing.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  hw/device-assignment.c |    6 ++++--
>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
>> index 4cc7b1a..7e965cb 100644
>> --- a/hw/device-assignment.c
>> +++ b/hw/device-assignment.c
>> @@ -1201,7 +1201,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>>  
>>      /* Expose MSI capability
>>       * MSI capability is the 1st capability in capability config */
>> -    if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0))) {
>> +    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
>> +    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
> 
> Is it even useful to have a device assigned w/o KVM_CAP_ASSIGN_DEV_IRQ?

If that feature is lacking, we fall back to the old KVM_ASSIGN_IRQ
interface. I guess that used to work, but I bet no one tested it
recently. However, the code is there, also in the kvm core.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it
  2011-08-02 17:32   ` Jan Kiszka
@ 2011-08-02 20:26     ` Alex Williamson
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2011-08-02 20:26 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm

On Tue, 2011-08-02 at 19:32 +0200, Jan Kiszka wrote:
> On 2011-08-02 19:02, Alex Williamson wrote:
> > On Tue, 2011-08-02 at 14:27 +0200, Jan Kiszka wrote:
> >> Add checks for KVM_CAP_ASSIGN_DEV_IRQ (MSI) and KVM_CAP_DEVICE_MSIX, do
> >> not set up MSI/MSI-X if the required kernel features are missing.
> >>
> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> >> ---
> >>  hw/device-assignment.c |    6 ++++--
> >>  1 files changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> >> index 4cc7b1a..7e965cb 100644
> >> --- a/hw/device-assignment.c
> >> +++ b/hw/device-assignment.c
> >> @@ -1201,7 +1201,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
> >>  
> >>      /* Expose MSI capability
> >>       * MSI capability is the 1st capability in capability config */
> >> -    if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0))) {
> >> +    pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
> >> +    if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
> > 
> > Is it even useful to have a device assigned w/o KVM_CAP_ASSIGN_DEV_IRQ?
> 
> If that feature is lacking, we fall back to the old KVM_ASSIGN_IRQ
> interface. I guess that used to work, but I bet no one tested it
> recently. However, the code is there, also in the kvm core.

Ah right.  Not sure how much I trust that, but seems obviously correct
to not expose capabilities we can't support.

Acked-by: Alex Williamson <alex.williamson@redhat.com>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it
  2011-08-02 12:27 [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it Jan Kiszka
  2011-08-02 17:02 ` Alex Williamson
@ 2011-08-03 20:29 ` Marcelo Tosatti
  1 sibling, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2011-08-03 20:29 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, kvm, Alex Williamson

On Tue, Aug 02, 2011 at 02:27:26PM +0200, Jan Kiszka wrote:
> Add checks for KVM_CAP_ASSIGN_DEV_IRQ (MSI) and KVM_CAP_DEVICE_MSIX, do
> not set up MSI/MSI-X if the required kernel features are missing.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/device-assignment.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-03 21:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-02 12:27 [PATCH] pci-assign: Do not expose MSI/MSI-X if the kernel does not support it Jan Kiszka
2011-08-02 17:02 ` Alex Williamson
2011-08-02 17:32   ` Jan Kiszka
2011-08-02 20:26     ` Alex Williamson
2011-08-03 20:29 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox