Patchwork kvm: set gsi_bits and max_gsi correctly

login
register
mail settings
Submitter Jason Baron
Date March 28, 2012, 6:18 p.m.
Message ID <201203281818.q2SII5ng021559@int-mx11.intmail.prod.int.phx2.redhat.com>
Download mbox | patch
Permalink /patch/149296/
State New
Headers show

Comments

Jason Baron - March 28, 2012, 6:18 p.m.
The current kvm_init_irq_routing() doesn't set up the used_gsi_bitmap
correctly, and as a consequence pins max_gsi to 32 when it really
should be 1024. I ran into this limitation while testing pci
passthrough, where I consistently got an -ENOSPC return from
kvm_get_irq_route_gsi() called from assigned_dev_update_msix_mmio().

Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 kvm-all.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Alex Williamson - March 28, 2012, 6:20 p.m.
On Wed, 2012-03-28 at 14:18 -0400, Jason Baron wrote:
> The current kvm_init_irq_routing() doesn't set up the used_gsi_bitmap
> correctly, and as a consequence pins max_gsi to 32 when it really
> should be 1024. I ran into this limitation while testing pci
> passthrough, where I consistently got an -ENOSPC return from
> kvm_get_irq_route_gsi() called from assigned_dev_update_msix_mmio().
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---
>  kvm-all.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index ab88c7c..b616c7d 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -873,7 +873,7 @@ static void kvm_init_irq_routing(KVMState *s)
>          unsigned int gsi_bits, i;
>  
>          /* Round up so we can search ints using ffs */
> -        gsi_bits = (gsi_count + 31) / 32;
> +        gsi_bits = ALIGN(gsi_count, 32);
>          s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
>          s->max_gsi = gsi_bits;
>  

Acked-by: Alex Williamson <alex.williamson@redhat.com>
Jan Kiszka - March 28, 2012, 6:27 p.m.
On 2012-03-28 20:20, Alex Williamson wrote:
> On Wed, 2012-03-28 at 14:18 -0400, Jason Baron wrote:
>> The current kvm_init_irq_routing() doesn't set up the used_gsi_bitmap
>> correctly, and as a consequence pins max_gsi to 32 when it really
>> should be 1024. I ran into this limitation while testing pci
>> passthrough, where I consistently got an -ENOSPC return from
>> kvm_get_irq_route_gsi() called from assigned_dev_update_msix_mmio().
>>
>> Signed-off-by: Jason Baron <jbaron@redhat.com>
>> ---
>>  kvm-all.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/kvm-all.c b/kvm-all.c
>> index ab88c7c..b616c7d 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -873,7 +873,7 @@ static void kvm_init_irq_routing(KVMState *s)
>>          unsigned int gsi_bits, i;
>>  
>>          /* Round up so we can search ints using ffs */
>> -        gsi_bits = (gsi_count + 31) / 32;
>> +        gsi_bits = ALIGN(gsi_count, 32);
>>          s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
>>          s->max_gsi = gsi_bits;
>>  
> 
> Acked-by: Alex Williamson <alex.williamson@redhat.com>
> 

Acked-by: Jan Kiszka <jan.kiszka@siemens.com>

Tagging this as "PATCH uq/master" may help Avi and Marcelo to identify
and pick it up for that queue.

Thanks,
Jan
Marcelo Tosatti - April 11, 2012, 2:14 a.m.
On Wed, Mar 28, 2012 at 02:18:05PM -0400, Jason Baron wrote:
> The current kvm_init_irq_routing() doesn't set up the used_gsi_bitmap
> correctly, and as a consequence pins max_gsi to 32 when it really
> should be 1024. I ran into this limitation while testing pci
> passthrough, where I consistently got an -ENOSPC return from
> kvm_get_irq_route_gsi() called from assigned_dev_update_msix_mmio().
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>

Applied to uq/master, thanks.

Patch

diff --git a/kvm-all.c b/kvm-all.c
index ab88c7c..b616c7d 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -873,7 +873,7 @@  static void kvm_init_irq_routing(KVMState *s)
         unsigned int gsi_bits, i;
 
         /* Round up so we can search ints using ffs */
-        gsi_bits = (gsi_count + 31) / 32;
+        gsi_bits = ALIGN(gsi_count, 32);
         s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
         s->max_gsi = gsi_bits;