* [PATCH] msix: fix msix_set/unset_mask_notifier
@ 2010-06-02 17:49 Michael S. Tsirkin
2010-06-02 18:26 ` Sridhar Samudrala
2010-06-04 16:57 ` Marcelo Tosatti
0 siblings, 2 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2010-06-02 17:49 UTC (permalink / raw)
To: kvm, Sridhar Samudrala
Sridhar Samudrala reported hitting the following assertions
in msix.c when doing a guest reboot or live migration using vhost.
qemu-kvm/hw/msix.c:375: msix_mask_all: Assertion `r >= 0' failed.
qemu-kvm/hw/msix.c:640: msix_unset_mask_notifier:
Assertion `dev->msix_mask_notifier_opaque[vector]' failed.
The issue is that we didn't clear/set the opaque pointer
when vector is masked. The following patch fixes this.
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Sridhar, could you test the following please?
hw/msix.c | 33 ++++++++++++++++-----------------
1 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/hw/msix.c b/hw/msix.c
index b400769..24ff6ae 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -610,7 +610,7 @@ void msix_unuse_all_vectors(PCIDevice *dev)
int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
{
- int r;
+ int r = 0;
if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
return 0;
@@ -619,13 +619,11 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
assert(!dev->msix_mask_notifier_opaque[vector]);
/* Unmask the new notifier unless vector is masked. */
- if (msix_is_masked(dev, vector)) {
- return 0;
- }
- r = dev->msix_mask_notifier(dev, vector, opaque,
- msix_is_masked(dev, vector));
- if (r < 0) {
- return r;
+ if (!msix_is_masked(dev, vector)) {
+ r = dev->msix_mask_notifier(dev, vector, opaque, false);
+ if (r < 0) {
+ return r;
+ }
}
dev->msix_mask_notifier_opaque[vector] = opaque;
return r;
@@ -634,21 +632,21 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector)
{
int r = 0;
+ void *opaque;
if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
return 0;
+ opaque = dev->msix_mask_notifier_opaque[vector];
+
assert(dev->msix_mask_notifier);
- assert(dev->msix_mask_notifier_opaque[vector]);
+ assert(opaque);
/* Mask the old notifier unless it is already masked. */
- if (msix_is_masked(dev, vector)) {
- return 0;
- }
- r = dev->msix_mask_notifier(dev, vector,
- dev->msix_mask_notifier_opaque[vector],
- !msix_is_masked(dev, vector));
- if (r < 0) {
- return r;
+ if (!msix_is_masked(dev, vector)) {
+ r = dev->msix_mask_notifier(dev, vector, opaque, true);
+ if (r < 0) {
+ return r;
+ }
}
dev->msix_mask_notifier_opaque[vector] = NULL;
return r;
--
1.7.1.12.g42b7f
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] msix: fix msix_set/unset_mask_notifier
2010-06-02 17:49 [PATCH] msix: fix msix_set/unset_mask_notifier Michael S. Tsirkin
@ 2010-06-02 18:26 ` Sridhar Samudrala
2010-06-04 16:57 ` Marcelo Tosatti
1 sibling, 0 replies; 3+ messages in thread
From: Sridhar Samudrala @ 2010-06-02 18:26 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm
On Wed, 2010-06-02 at 20:49 +0300, Michael S. Tsirkin wrote:
> Sridhar Samudrala reported hitting the following assertions
> in msix.c when doing a guest reboot or live migration using vhost.
> qemu-kvm/hw/msix.c:375: msix_mask_all: Assertion `r >= 0' failed.
> qemu-kvm/hw/msix.c:640: msix_unset_mask_notifier:
> Assertion `dev->msix_mask_notifier_opaque[vector]' failed.
>
> The issue is that we didn't clear/set the opaque pointer
> when vector is masked. The following patch fixes this.
>
> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Sridhar, could you test the following please?
Yes. looks good and works fine for me.
Tested-by: Sridhar Samudrala <sri@us.ibm.com
>
> hw/msix.c | 33 ++++++++++++++++-----------------
> 1 files changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/hw/msix.c b/hw/msix.c
> index b400769..24ff6ae 100644
> --- a/hw/msix.c
> +++ b/hw/msix.c
> @@ -610,7 +610,7 @@ void msix_unuse_all_vectors(PCIDevice *dev)
>
> int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
> {
> - int r;
> + int r = 0;
> if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
> return 0;
>
> @@ -619,13 +619,11 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
> assert(!dev->msix_mask_notifier_opaque[vector]);
>
> /* Unmask the new notifier unless vector is masked. */
> - if (msix_is_masked(dev, vector)) {
> - return 0;
> - }
> - r = dev->msix_mask_notifier(dev, vector, opaque,
> - msix_is_masked(dev, vector));
> - if (r < 0) {
> - return r;
> + if (!msix_is_masked(dev, vector)) {
> + r = dev->msix_mask_notifier(dev, vector, opaque, false);
> + if (r < 0) {
> + return r;
> + }
> }
> dev->msix_mask_notifier_opaque[vector] = opaque;
> return r;
> @@ -634,21 +632,21 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
> int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector)
> {
> int r = 0;
> + void *opaque;
> if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
> return 0;
>
> + opaque = dev->msix_mask_notifier_opaque[vector];
> +
> assert(dev->msix_mask_notifier);
> - assert(dev->msix_mask_notifier_opaque[vector]);
> + assert(opaque);
>
> /* Mask the old notifier unless it is already masked. */
> - if (msix_is_masked(dev, vector)) {
> - return 0;
> - }
> - r = dev->msix_mask_notifier(dev, vector,
> - dev->msix_mask_notifier_opaque[vector],
> - !msix_is_masked(dev, vector));
> - if (r < 0) {
> - return r;
> + if (!msix_is_masked(dev, vector)) {
> + r = dev->msix_mask_notifier(dev, vector, opaque, true);
> + if (r < 0) {
> + return r;
> + }
> }
> dev->msix_mask_notifier_opaque[vector] = NULL;
> return r;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] msix: fix msix_set/unset_mask_notifier
2010-06-02 17:49 [PATCH] msix: fix msix_set/unset_mask_notifier Michael S. Tsirkin
2010-06-02 18:26 ` Sridhar Samudrala
@ 2010-06-04 16:57 ` Marcelo Tosatti
1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2010-06-04 16:57 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, Sridhar Samudrala
On Wed, Jun 02, 2010 at 08:49:35PM +0300, Michael S. Tsirkin wrote:
> Sridhar Samudrala reported hitting the following assertions
> in msix.c when doing a guest reboot or live migration using vhost.
> qemu-kvm/hw/msix.c:375: msix_mask_all: Assertion `r >= 0' failed.
> qemu-kvm/hw/msix.c:640: msix_unset_mask_notifier:
> Assertion `dev->msix_mask_notifier_opaque[vector]' failed.
>
> The issue is that we didn't clear/set the opaque pointer
> when vector is masked. The following patch fixes this.
>
> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Sridhar, could you test the following please?
>
> hw/msix.c | 33 ++++++++++++++++-----------------
> 1 files changed, 16 insertions(+), 17 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-04 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02 17:49 [PATCH] msix: fix msix_set/unset_mask_notifier Michael S. Tsirkin
2010-06-02 18:26 ` Sridhar Samudrala
2010-06-04 16:57 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).