Skip to contentSkip to conversation

dma/i82374: avoid double creation of i82374 device

PATCH Applied Eduardo Otubo 4 participants 12 messages Sep 15, 2017 – Sep 25, 2017

v1 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma/i82374: avoid double creation of i82374 device

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

A possible fix in a near future would be making isa_bus_dma()/DMA_init()/i82374_realize() return an error instead of asserting as well.

---
 hw/dma/i82374.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/dma/i82374.c +5 -0
index 6c0f975df0..e76dea8dc7 100644
@@ -139,6 +139,11 @@ static void i82374_class_init(ObjectClass *klass, void *data)
     dc->realize = i82374_realize;
     dc->vmsd = &vmstate_i82374;
     dc->props = i82374_properties;
+    dc->user_creatable = false;
+    /*
+     * Reason: i82374_realize() crashes (assertion failure inside isa_bus_dma()
+     *         if the device is instantiated twice.
+     */
 }
 
 static const TypeInfo i82374_info = {
Signature · 1 line
2.13.5
#1 lore raw

(oups, forgot the v2 on Subject)

Quoted 40 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

A possible fix in a near future would be making isa_bus_dma()/DMA_init()/i82374_realize() return an error instead of asserting as well.

---
 hw/dma/i82374.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/dma/i82374.c +5 -0
index 6c0f975df0..e76dea8dc7 100644
@@ -139,6 +139,11 @@ static void i82374_class_init(ObjectClass *klass, void *data)
     dc->realize = i82374_realize;
     dc->vmsd = &vmstate_i82374;
     dc->props = i82374_properties;
+    dc->user_creatable = false;
+    /*
+     * Reason: i82374_realize() crashes (assertion failure inside isa_bus_dma()
+     *         if the device is instantiated twice.
+     */
 }
 
 static const TypeInfo i82374_info = {
Signature · 1 line
2.13.5
Signature · 2 lines
Eduardo Otubo
Senior Software Engineer @ RedHat
#2 lore raw
In reply to Eduardo Otubo
Quoted 27 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

A possible fix in a near future would be making isa_bus_dma()/DMA_init()/i82374_realize() return an error instead of asserting as well.

---
 hw/dma/i82374.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/dma/i82374.c +0 -0
index 6c0f975df0..e76dea8dc7 100644
@@ -139,6 +139,11 @@ static void i82374_class_init(ObjectClass *klass, void *data)
     dc->realize = i82374_realize;

hw/dma/i82374.c static void i82374_class_init(ObjectClass *klass, void *data) · line 149

Quoted 10 lines
hw/dma/i82374.c +5 -0
     dc->vmsd = &vmstate_i82374;
     dc->props = i82374_properties;
+    dc->user_creatable = false;
+    /*
+     * Reason: i82374_realize() crashes (assertion failure inside isa_bus_dma()
+     *         if the device is instantiated twice.
+     */
 }
 
 static const TypeInfo i82374_info = {

This breaks "make check", doesn't it?

v2 should be the one that returns an error instead of asserting.

Paolo

#3 lore raw
Quoted 36 lines · Paolo Bonzini
Quoted 35 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

A possible fix in a near future would be making isa_bus_dma()/DMA_init()/i82374_realize() return an error instead of asserting as well.

---
 hw/dma/i82374.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/dma/i82374.c +5 -0
index 6c0f975df0..e76dea8dc7 100644
@@ -139,6 +139,11 @@ static void i82374_class_init(ObjectClass *klass, void *data)
     dc->realize = i82374_realize;
     dc->vmsd = &vmstate_i82374;
     dc->props = i82374_properties;
+    dc->user_creatable = false;
+    /*
+     * Reason: i82374_realize() crashes (assertion failure inside isa_bus_dma()
+     *         if the device is instantiated twice.
+     */
 }
 
Quoted 6 lines

hw/dma/i82374.c static void i82374_class_init(ObjectClass *klass, void *data) · line 149

Quoted 2 lines
hw/dma/i82374.c +0 -0
 static const TypeInfo i82374_info = {

This breaks "make check", doesn't it?

v2 should be the one that returns an error instead of asserting.

I guess I have misunderstood, then. I'll work on a patch to propagate the error then.

Thanks,

Signature · 2 lines
Eduardo Otubo
Senior Software Engineer @ RedHat
#4 lore raw
In reply to Paolo Bonzini
Quoted 36 lines · Paolo Bonzini
Quoted 35 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

A possible fix in a near future would be making isa_bus_dma()/DMA_init()/i82374_realize() return an error instead of asserting as well.

---
 hw/dma/i82374.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/dma/i82374.c +5 -0
index 6c0f975df0..e76dea8dc7 100644
@@ -139,6 +139,11 @@ static void i82374_class_init(ObjectClass *klass, void *data)
     dc->realize = i82374_realize;
     dc->vmsd = &vmstate_i82374;
     dc->props = i82374_properties;
+    dc->user_creatable = false;
+    /*
+     * Reason: i82374_realize() crashes (assertion failure inside isa_bus_dma()
+     *         if the device is instantiated twice.
+     */
 }
 
Quoted 4 lines

hw/dma/i82374.c static void i82374_class_init(ObjectClass *klass, void *data) · line 149

Quoted 2 lines
hw/dma/i82374.c +0 -0
 static const TypeInfo i82374_info = {

This breaks "make check", doesn't it?

Why would it? I don't see any test code using -device i82374. (endianness-test uses -device i82378).

Quoted 2 lines

v2 should be the one that returns an error instead of asserting.

I agree that returning an error is better.

Signature · 1 line
Eduardo
#5 lore raw

----- Original Message -----

Quoted 52 lines

From: "Eduardo Habkost" <[email protected]>
To: "Paolo Bonzini" <[email protected]>
Cc: "Eduardo Otubo" <[email protected]>, [email protected], [email protected], "Michael Tokarev" <[email protected]>, "Markus Armbruster" <[email protected]>, "Alexander Graf" <[email protected]>
Sent: Saturday, September 16, 2017 12:21:13 AM
Subject: Re: [PATCH] dma/i82374: avoid double creation of i82374 device

Quoted 44 lines · Paolo Bonzini
Quoted 43 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed.
Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the
command line, it will try to create it again, hence generating the error. The
function isa_bus_dma() isn't supposed to be called twice for the same bus. One
way to avoid this problem is to set user_creatable=false.

A possible fix in a near future would be making isa_bus_dma()/DMA_init()/i82374_realize() return an error instead of asserting
as well.

---
 hw/dma/i82374.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/dma/i82374.c +5 -0
index 6c0f975df0..e76dea8dc7 100644
@@ -139,6 +139,11 @@ static void i82374_class_init(ObjectClass *klass,
 void *data)
     dc->realize = i82374_realize;
     dc->vmsd = &vmstate_i82374;
     dc->props = i82374_properties;
+    dc->user_creatable = false;
+    /*
+     * Reason: i82374_realize() crashes (assertion failure inside
 isa_bus_dma()
+     *         if the device is instantiated twice.
+     */
 }
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

static const TypeInfo i82374_info = {

This breaks "make check", doesn't it?

Why would it? I don't see any test code using -device i82374. (endianness-test uses -device i82378).

You're right, both Aurelien and I were confused. If you want to accept this patch it would be fine then, even if giving an error may be preferrable.

Paolo

#6 lore raw
In reply to Eduardo Otubo
Quoted 10 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

Applied to -trivial, thanks!

/mjt

#7 lore raw
Quoted 7 lines · Michael Tokarev
Quoted 6 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

Quoted 6 lines
Quoted 4 lines

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

Applied to -trivial, thanks!

Eduardo, weren't you going to send a version that propagates Error* correctly instead?

Paolo

#8 lore raw
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Michael Tokarev
Quoted 10 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

Quoted 4 lines
Quoted 1 line

Applied to -trivial, thanks!

Eduardo, weren't you going to send a version that propagates Error* correctly instead?

Yes, that's correct. I can revert this patch with the error propagation patch as well, if you guys don't mind.

#9 lore raw
Quoted 14 lines · Eduardo Otubo
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Michael Tokarev
Quoted 10 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Applied to -trivial, thanks!

Eduardo, weren't you going to send a version that propagates Error* correctly instead?

Yes, that's correct. I can revert this patch with the error propagation patch as well, if you guys don't mind.

Sure, that's fine too.

Paolo

#10 lore raw
In reply to Eduardo Otubo
Quoted 14 lines · Eduardo Otubo
Quoted 13 lines · Paolo Bonzini
Quoted 12 lines · Michael Tokarev
Quoted 10 lines · Eduardo Otubo

QEMU fails when used with the following command line:

./ppc64-softmmu/qemu-system-ppc64 -S -machine 40p,accel=tcg -device i82374
qemu-system-ppc64: hw/isa/isa-bus.c:110: isa_bus_dma: Assertion `!bus->dma[0] && !bus->dma[1]' failed. Aborted (core dumped)

The 40p machine type already creates the device i82374. If specified in the command line, it will try to create it again, hence generating the error. The function isa_bus_dma() isn't supposed to be called twice for the same bus. One way to avoid this problem is to set user_creatable=false.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Applied to -trivial, thanks!

Eduardo, weren't you going to send a version that propagates Error* correctly instead?

Yes, that's correct. I can revert this patch with the error propagation patch as well, if you guys don't mind.

Hmm. After reading the original discussion I concluded this patch is okay. I can remove it right now before the series has been applied, together with another tiny change.

Thanks,

/mjt

#11 lore raw
Quoted 5 lines · Michael Tokarev
Quoted 2 lines

Yes, that's correct. I can revert this patch with the error propagation patch as well, if you guys don't mind.

Hmm. After reading the original discussion I concluded this patch is okay. I can remove it right now before the series has been applied, together with another tiny change.

No problem, it's okay for now as a trivial change.

Paolo