Skip to contentSkip to conversation

qemu-kvm: reserve the low 24 gsi values

PATCH In review Michael S. Tsirkin 2 participants 3 messages Jul 21, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-kvm: reserve the low 24 gsi values

reserve gsi 0 to 23 so that they won't be allocated for msi

---

qemu-kvm.c +4 -2
index c6c9fc6..f440b2d 100644
@@ -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;
 
#1 lore raw
Quoted 2 lines · Michael S. Tsirkin

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?

Quoted 13 lines

---

qemu-kvm.c +1 -0
index c6c9fc6..f440b2d 100644
@@ -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;

qemu-kvm.c int kvm_get_irq_route_gsi(kvm_context_t kvm) · line 1624

Quoted 10 lines
qemu-kvm.c +3 -2
 
 	/* 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.

#2 lore raw
Quoted 5 lines · Gleb Natapov
Quoted 2 lines · Michael S. Tsirkin

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?

Quoted 2 lines

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.

Quoted 3 lines

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?

Quoted 26 lines
Quoted 13 lines

---

qemu-kvm.c +1 -0
index c6c9fc6..f440b2d 100644
@@ -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;

qemu-kvm.c int kvm_get_irq_route_gsi(kvm_context_t kvm) · line 1624

Quoted 10 lines
qemu-kvm.c +3 -2
 
 	/* 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.