All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
@ 2014-10-27 16:41 Marcel Apfelbaum
  2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 1/2] hw/pci: fixed error flow in pci_qdev_init Marcel Apfelbaum
  2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
  0 siblings, 2 replies; 6+ messages in thread
From: Marcel Apfelbaum @ 2014-10-27 16:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, pbonzini, alex.williamson, armbru, mst

Hot-plugging a device that has a romfile (either supplied by user
or built-in) using rombar=0 option is an user error,
do not allow the device to be hot-plugged.

v2 -> v3:
 - Reverse the decision to forbit the hotplug on user error (Michael S. Tsirkin)
 - Split the patch in two, first part being a separate fix (Markus Armbruster)  

v1 -> v2:
 After a discussion with Michael, Paolo and Alex, this
 patch silent drops the romfile instead of not allowing
 the hotplug.

Marcel Apfelbaum (2):
  hw/pci: fixed error flow in pci_qdev_init
  hw/pci: fixed hotplug crash when using rombar=0 with devices having
    romfile

 hw/pci/pci.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v3 1/2] hw/pci: fixed error flow in pci_qdev_init
  2014-10-27 16:41 [Qemu-devel] [PATCH v3 0/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
@ 2014-10-27 16:41 ` Marcel Apfelbaum
  2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
  1 sibling, 0 replies; 6+ messages in thread
From: Marcel Apfelbaum @ 2014-10-27 16:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, pbonzini, alex.williamson, armbru, mst

Verify return code for pci_add_option_rom.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/pci/pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6ce75aa..36226eb 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1776,7 +1776,12 @@ static int pci_qdev_init(DeviceState *qdev)
         pci_dev->romfile = g_strdup(pc->romfile);
         is_default_rom = true;
     }
-    pci_add_option_rom(pci_dev, is_default_rom);
+
+    rc = pci_add_option_rom(pci_dev, is_default_rom);
+    if (rc != 0) {
+        pci_unregister_device(DEVICE(pci_dev));
+        return rc;
+    }
 
     return 0;
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
  2014-10-27 16:41 [Qemu-devel] [PATCH v3 0/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
  2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 1/2] hw/pci: fixed error flow in pci_qdev_init Marcel Apfelbaum
@ 2014-10-27 16:41 ` Marcel Apfelbaum
  2014-10-27 17:10   ` Eric Blake
  1 sibling, 1 reply; 6+ messages in thread
From: Marcel Apfelbaum @ 2014-10-27 16:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcel, pbonzini, alex.williamson, armbru, mst

Hot-plugging a device that has a romfile (either supplied by user
or built-in) using rombar=0 option is an user error,
do not allow the device to be hot-plugged.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 hw/pci/pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 36226eb..371699c 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1942,6 +1942,15 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
          * for 0.11 compatibility.
          */
         int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+
+        /*
+         * Hot-plugged devices can't use the option ROM
+         * if the rom bar is disabled.
+         */
+        if (DEVICE(pdev)->hotplugged) {
+            return -1;
+        }
+
         if (class == 0x0300) {
             rom_add_vga(pdev->romfile);
         } else {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
  2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
@ 2014-10-27 17:10   ` Eric Blake
  2014-10-27 17:15     ` Marcel Apfelbaum
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2014-10-27 17:10 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel
  Cc: marcel, pbonzini, alex.williamson, armbru, mst

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

On 10/27/2014 10:41 AM, Marcel Apfelbaum wrote:
> Hot-plugging a device that has a romfile (either supplied by user
> or built-in) using rombar=0 option is an user error,

s/an/a/ (user is pronounced with a leading hard "y" sound rather than a
soft "u", it may help to remember you can "give a unicorn an umbrella")

> do not allow the device to be hot-plugged.
> 
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> ---
>  hw/pci/pci.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
  2014-10-27 17:10   ` Eric Blake
@ 2014-10-27 17:15     ` Marcel Apfelbaum
  2014-10-27 17:21       ` Michael S. Tsirkin
  0 siblings, 1 reply; 6+ messages in thread
From: Marcel Apfelbaum @ 2014-10-27 17:15 UTC (permalink / raw)
  To: Eric Blake; +Cc: mst, qemu-devel, armbru, alex.williamson, marcel, pbonzini

On Mon, 2014-10-27 at 11:10 -0600, Eric Blake wrote:
> On 10/27/2014 10:41 AM, Marcel Apfelbaum wrote:
> > Hot-plugging a device that has a romfile (either supplied by user
> > or built-in) using rombar=0 option is an user error,
> 
> s/an/a/ (user is pronounced with a leading hard "y" sound rather than a
> soft "u", it may help to remember you can "give a unicorn an umbrella")
Thanks, still hard to get it right, but your tip will surely help :)

Michael, do you want me to send another version,
or you can change it on the fly?

Thanks,
Marcel

> 
> > do not allow the device to be hot-plugged.
> > 
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > ---
> >  hw/pci/pci.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
  2014-10-27 17:15     ` Marcel Apfelbaum
@ 2014-10-27 17:21       ` Michael S. Tsirkin
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2014-10-27 17:21 UTC (permalink / raw)
  To: Marcel Apfelbaum; +Cc: qemu-devel, armbru, alex.williamson, marcel, pbonzini

On Mon, Oct 27, 2014 at 07:15:38PM +0200, Marcel Apfelbaum wrote:
> On Mon, 2014-10-27 at 11:10 -0600, Eric Blake wrote:
> > On 10/27/2014 10:41 AM, Marcel Apfelbaum wrote:
> > > Hot-plugging a device that has a romfile (either supplied by user
> > > or built-in) using rombar=0 option is an user error,
> > 
> > s/an/a/ (user is pronounced with a leading hard "y" sound rather than a
> > soft "u", it may help to remember you can "give a unicorn an umbrella")
> Thanks, still hard to get it right, but your tip will surely help :)
> 
> Michael, do you want me to send another version,
> or you can change it on the fly?
> 
> Thanks,
> Marcel

go ahead and repost, easier for me.

> > 
> > > do not allow the device to be hot-plugged.
> > > 
> > > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > > ---
> > >  hw/pci/pci.c | 9 +++++++++
> > >  1 file changed, 9 insertions(+)
> > > 
> > 
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> > 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-10-27 17:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-27 16:41 [Qemu-devel] [PATCH v3 0/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 1/2] hw/pci: fixed error flow in pci_qdev_init Marcel Apfelbaum
2014-10-27 16:41 ` [Qemu-devel] [PATCH v3 2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile Marcel Apfelbaum
2014-10-27 17:10   ` Eric Blake
2014-10-27 17:15     ` Marcel Apfelbaum
2014-10-27 17:21       ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.