Skip to contentSkip to conversation

KVM: Correct deliver_bitmask in kvm_get_intr_delivery_bitmask

PATCH In review Sheng Yang 2 participants 3 messages Feb 27, 2009 – Mar 2, 2009 KVM

lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 KVM: Correct deliver_bitmask in kvm_get_intr_delivery_bitmask

1. deliver_bitmask is a bitmap rather than a unsigned long intereger.
2. Lowest priority target bitmap wrong calculated by mistake.
3. Prevent potential NULL reference.

---
 virt/kvm/irq_comm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
virt/kvm/irq_comm.c +5 -1
index d165e05..8e1869d 100644
@@ -54,8 +54,12 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic,
 					deliver_bitmask);
 	switch (entry->fields.delivery_mode) {
 	case IOAPIC_LOWEST_PRIORITY:
+		/* Select one in deliver_bitmask */
 		vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm,
 				entry->fields.vector, deliver_bitmask);
+		bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
+		if (!vcpu)
+			return;
 		__set_bit(vcpu->vcpu_id, deliver_bitmask);
 		break;
 	case IOAPIC_FIXED:
@@ -65,7 +69,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic,
 		if (printk_ratelimit())
 			printk(KERN_INFO "kvm: unsupported delivery mode %d\n",
 				entry->fields.delivery_mode);
-		*deliver_bitmask = 0;
+		bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
 	}
 }
 
Signature · 1 line
1.5.4.5
#1 lore raw
Quoted 15 lines · Sheng Yang

1. deliver_bitmask is a bitmap rather than a unsigned long intereger.
2. Lowest priority target bitmap wrong calculated by mistake.
3. Prevent potential NULL reference.

---
 virt/kvm/irq_comm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
virt/kvm/irq_comm.c +0 -0
index d165e05..8e1869d 100644
@@ -54,8 +54,12 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic,
 					deliver_bitmask);

virt/kvm/irq_comm.c void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, · line 64

Quoted 10 lines
virt/kvm/irq_comm.c +4 -0
 	switch (entry->fields.delivery_mode) {
 	case IOAPIC_LOWEST_PRIORITY:
+		/* Select one in deliver_bitmask */
 		vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm,
 				entry->fields.vector, deliver_bitmask);
+		bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
+		if (!vcpu)
+			return;
 		__set_bit(vcpu->vcpu_id, deliver_bitmask);
 		break;

The only caller of kvm_ioapic_get_delivery_bitmask() is kvm_get_intr_delivery_bitmask() why not add delivery_mode parameter to kvm_ioapic_get_delivery_bitmask() and get rid of kvm_get_intr_delivery_bitmask()?

Quoted 12 lines
virt/kvm/irq_comm.c +1 -1
 	case IOAPIC_FIXED:
@@ -65,7 +69,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic,
 		if (printk_ratelimit())
 			printk(KERN_INFO "kvm: unsupported delivery mode %d\n",
 				entry->fields.delivery_mode);
-		*deliver_bitmask = 0;
+		bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
 	}
 }
 
Signature · 1 line
1.5.4.5

--
Gleb.

author
#2 lore raw
Quoted 23 lines · On Monday 02 March 2009 15:12:52 Gleb Natapov wrote:
Quoted 22 lines · Sheng Yang

1. deliver_bitmask is a bitmap rather than a unsigned long intereger.
2. Lowest priority target bitmap wrong calculated by mistake.
3. Prevent potential NULL reference.

---
 virt/kvm/irq_comm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
virt/kvm/irq_comm.c +3 -0
index d165e05..8e1869d 100644
@@ -54,8 +54,12 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic
 *ioapic, deliver_bitmask);
 	switch (entry->fields.delivery_mode) {
 	case IOAPIC_LOWEST_PRIORITY:
+		/* Select one in deliver_bitmask */
 		vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm,
 				entry->fields.vector, deliver_bitmask);
+		bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
+		if (!vcpu)
Quoted 8 lines

virt/kvm/irq_comm.c void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, · line 64

Quoted 3 lines
virt/kvm/irq_comm.c +1 -0
+			return;
 		__set_bit(vcpu->vcpu_id, deliver_bitmask);
 		break;

The only caller of kvm_ioapic_get_delivery_bitmask() is kvm_get_intr_delivery_bitmask() why not add delivery_mode parameter to kvm_ioapic_get_delivery_bitmask() and get rid of kvm_get_intr_delivery_bitmask()?

Oh yeah, that's right. I think it's OK to merge kvm_ioapic_get_delivery_bitmask() into kvm_get_intr_delivery_bitmask(). If no objection, I would send a patch to merge them.

Thanks.

Signature · 2 lines
regards
Yang, Sheng
Quoted 16 lines
Quoted 12 lines
virt/kvm/irq_comm.c +1 -2
 	case IOAPIC_FIXED:
@@ -65,7 +69,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic
 *ioapic, if (printk_ratelimit())
 			printk(KERN_INFO "kvm: unsupported delivery mode %d\n",
 				entry->fields.delivery_mode);
-		*deliver_bitmask = 0;
+		bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
 	}
 }
 
--
Quoted 1 line

1.5.4.5

--
Gleb.