diff mbox

qemu-kvm: reserve the low 24 gsi values

Message ID 20090721155742.GC3229@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael S. Tsirkin July 21, 2009, 3:57 p.m. UTC
reserve gsi 0 to 23 so that they won't be allocated for msi

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

---

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Gleb Natapov July 21, 2009, 5:21 p.m. UTC | #1
On Tue, Jul 21, 2009 at 06:57:42PM +0300, Michael S. Tsirkin wrote:
> reserve gsi 0 to 23 so that they won't be allocated for msi
> 
In the not so distant future we may want to support more then one
ioapic, so 23 will became 23*n where n is a number of ioapics. I prefer
to fix it by moving msi injection to its own ioctl. But for now may be
we can scan used_gsi_bitmap from the end during allocation of gsi for
msi?

> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> ---
> 
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index c6c9fc6..f440b2d 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -1613,10 +1613,12 @@ int kvm_get_irq_route_gsi(kvm_context_t kvm)
>  {
>  	int i, bit;
>  	uint32_t *buf = kvm->used_gsi_bitmap;
> +	uint32_t mask = 0xff000000;
>  
>  	/* Return the lowest unused GSI in the bitmap */
> -	for (i = 0; i < kvm->max_gsi / 32; i++) {
> -		bit = ffs(~buf[i]);
> +	for (i = 0; i < kvm->max_gsi / 32; i++) {
> +		bit = ffs(~buf[i] & mask);
> +		mask = 0xffffffff;
>  		if (!bit)
>  			continue;
>  

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michael S. Tsirkin July 21, 2009, 8:23 p.m. UTC | #2
On Tue, Jul 21, 2009 at 08:21:15PM +0300, Gleb Natapov wrote:
> On Tue, Jul 21, 2009 at 06:57:42PM +0300, Michael S. Tsirkin wrote:
> > reserve gsi 0 to 23 so that they won't be allocated for msi
> > 
> In the not so distant future we may want to support more then one
> ioapic, so 23 will became 23*n where n is a number of ioapics.

Hmm, n is not limited here, is it?

> I prefer
> to fix it by moving msi injection to its own ioctl.

We will have to figure out how to do this in a backwards-compatible way.

> But for now may be
> we can scan used_gsi_bitmap from the end during allocation of gsi for
> msi?

Right, but I think we also want to fail allocations with number < 24
at least for now?

> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > 
> > ---
> > 
> > diff --git a/qemu-kvm.c b/qemu-kvm.c
> > index c6c9fc6..f440b2d 100644
> > --- a/qemu-kvm.c
> > +++ b/qemu-kvm.c
> > @@ -1613,10 +1613,12 @@ int kvm_get_irq_route_gsi(kvm_context_t kvm)
> >  {
> >  	int i, bit;
> >  	uint32_t *buf = kvm->used_gsi_bitmap;
> > +	uint32_t mask = 0xff000000;
> >  
> >  	/* Return the lowest unused GSI in the bitmap */
> > -	for (i = 0; i < kvm->max_gsi / 32; i++) {
> > -		bit = ffs(~buf[i]);
> > +	for (i = 0; i < kvm->max_gsi / 32; i++) {
> > +		bit = ffs(~buf[i] & mask);
> > +		mask = 0xffffffff;
> >  		if (!bit)
> >  			continue;
> >  
> 
> --
> 			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/qemu-kvm.c b/qemu-kvm.c
index c6c9fc6..f440b2d 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1613,10 +1613,12 @@  int kvm_get_irq_route_gsi(kvm_context_t kvm)
 {
 	int i, bit;
 	uint32_t *buf = kvm->used_gsi_bitmap;
+	uint32_t mask = 0xff000000;
 
 	/* Return the lowest unused GSI in the bitmap */
-	for (i = 0; i < kvm->max_gsi / 32; i++) {
-		bit = ffs(~buf[i]);
+	for (i = 0; i < kvm->max_gsi / 32; i++) {
+		bit = ffs(~buf[i] & mask);
+		mask = 0xffffffff;
 		if (!bit)
 			continue;