Skip to contentSkip to conversation

virt/kvm/assigned-dev.c: Set 'dev->irq_source_id' to '-1' after free it

PATCH In review Chen Gang 2 participants 6 messages Aug 8, 2014 – Aug 20, 2014 KVM

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 virt/kvm/assigned-dev.c: Set 'dev->irq_source_id' to '-1' after free it

As a generic function, deassign_guest_irq() assumes it can be called even if assign_guest_irq() is not be called successfully (which can be triggered by ioctl from user mode, indirectly).

So for assign_guest_irq() failure process, need set 'dev->irq_source_id' to -1 after free 'dev->irq_source_id', or deassign_guest_irq() may free it again.

---
 virt/kvm/assigned-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
virt/kvm/assigned-dev.c +3 -1
index bf06577..5819a27 100644
@@ -526,8 +526,10 @@ static int assign_guest_irq(struct kvm *kvm,
 		dev->irq_requested_type |= guest_irq_type;
 		if (dev->ack_notifier.gsi != -1)
 			kvm_register_irq_ack_notifier(kvm, &dev->ack_notifier);
-	} else
+	} else {
 		kvm_free_irq_source_id(kvm, dev->irq_source_id);
+		dev->irq_source_id = -1;
+	}
 
 	return r;
 }
Signature · 1 line
1.7.11.7
author
#1 lore raw

Hello maintainers:

Please help check this patch, when you have time.

Thanks.

Quoted 30 lines · Chen Gang

As a generic function, deassign_guest_irq() assumes it can be called even if assign_guest_irq() is not be called successfully (which can be triggered by ioctl from user mode, indirectly).

So for assign_guest_irq() failure process, need set 'dev->irq_source_id' to -1 after free 'dev->irq_source_id', or deassign_guest_irq() may free it again.

---
 virt/kvm/assigned-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
virt/kvm/assigned-dev.c +3 -1
index bf06577..5819a27 100644
@@ -526,8 +526,10 @@ static int assign_guest_irq(struct kvm *kvm,
 		dev->irq_requested_type |= guest_irq_type;
 		if (dev->ack_notifier.gsi != -1)
 			kvm_register_irq_ack_notifier(kvm, &dev->ack_notifier);
-	} else
+	} else {
 		kvm_free_irq_source_id(kvm, dev->irq_source_id);
+		dev->irq_source_id = -1;
+	}
 
 	return r;
 }
Signature · 3 lines
Chen Gang

Open share and attitude like air water and life which God blessed
maintainer
#2 lore raw

Il 19/08/2014 17:44, Chen Gang ha scritto:

Quoted 3 lines

Hello maintainers:

Please help check this patch, when you have time.

Hi, it's already on its way to 3.17-rc2, but I first have to run a bunch of tests.

Paolo

Quoted 33 lines

Thanks.

Quoted 30 lines · Chen Gang

As a generic function, deassign_guest_irq() assumes it can be called even if assign_guest_irq() is not be called successfully (which can be triggered by ioctl from user mode, indirectly).

So for assign_guest_irq() failure process, need set 'dev->irq_source_id' to -1 after free 'dev->irq_source_id', or deassign_guest_irq() may free it again.

---
 virt/kvm/assigned-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
virt/kvm/assigned-dev.c +3 -1
index bf06577..5819a27 100644
@@ -526,8 +526,10 @@ static int assign_guest_irq(struct kvm *kvm,
 		dev->irq_requested_type |= guest_irq_type;
 		if (dev->ack_notifier.gsi != -1)
 			kvm_register_irq_ack_notifier(kvm, &dev->ack_notifier);
-	} else
+	} else {
 		kvm_free_irq_source_id(kvm, dev->irq_source_id);
+		dev->irq_source_id = -1;
+	}
 
 	return r;
 }
author
#3 lore raw
Quoted 6 lines · Paolo Bonzini

Il 19/08/2014 17:44, Chen Gang ha scritto:

Quoted 3 lines
Quoted 3 lines

Hello maintainers:

Please help check this patch, when you have time.

Hi, it's already on its way to 3.17-rc2, but I first have to run a bunch of tests.

OK, thanks. Also can let me try the test, although I am not quite familiar with KVM. Since I plan to focus on KVM/Xen next, I shall construct related environments for its' common test, at least.

I am just constructing the gcc common test environments under a new PC, is a PC also enough for KVM/Xen common test?

Welcome any ideas, suggestions or completions about it (especially the information about KVM/Xen common test).

Thanks.

Signature · 3 lines
Chen Gang

Open share and attitude like air water and life which God blessed
author
#4 lore raw

By the way, at present, I use Qemu as user mode program, is there common test with both Qemu and KVM/Xen? And is a PC enough for the common test?

Thanks.

Quoted 21 lines · Chen Gang
Quoted 6 lines · Paolo Bonzini

Il 19/08/2014 17:44, Chen Gang ha scritto:

Quoted 3 lines
Quoted 3 lines

Hello maintainers:

Please help check this patch, when you have time.

Hi, it's already on its way to 3.17-rc2, but I first have to run a bunch of tests.

OK, thanks. Also can let me try the test, although I am not quite familiar with KVM. Since I plan to focus on KVM/Xen next, I shall construct related environments for its' common test, at least.

I am just constructing the gcc common test environments under a new PC, is a PC also enough for KVM/Xen common test?

Welcome any ideas, suggestions or completions about it (especially the information about KVM/Xen common test).

Thanks.

Signature · 3 lines
Chen Gang

Open share and attitude like air water and life which God blessed
author
#5 lore raw
Quoted 4 lines · Chen Gang

By the way, at present, I use Qemu as user mode program, is there common test with both Qemu and KVM/Xen? And is a PC enough for the common test?

Oh, I find Qemu have "make check" just like gcc/binutils, so for each of my patch, next, shall run "./configure && make && make check" at least.

And also welcome any additional ideas, suggestions or completions about test for kvm/xen/qemu.

Thanks.

Quoted 25 lines · Chen Gang
Quoted 21 lines · Paolo Bonzini
Quoted 6 lines

Il 19/08/2014 17:44, Chen Gang ha scritto:

Quoted 3 lines
Quoted 3 lines

Hello maintainers:

Please help check this patch, when you have time.

Hi, it's already on its way to 3.17-rc2, but I first have to run a bunch of tests.

OK, thanks. Also can let me try the test, although I am not quite familiar with KVM. Since I plan to focus on KVM/Xen next, I shall construct related environments for its' common test, at least.

I am just constructing the gcc common test environments under a new PC, is a PC also enough for KVM/Xen common test?

Welcome any ideas, suggestions or completions about it (especially the information about KVM/Xen common test).

Thanks.

Signature · 3 lines
Chen Gang

Open share and attitude like air water and life which God blessed