diff mbox

[v3,2/2] hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile

Message ID 1414428082-7341-3-git-send-email-marcel.a@redhat.com
State New
Headers show

Commit Message

Marcel Apfelbaum Oct. 27, 2014, 4:41 p.m. UTC
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(+)

Comments

Eric Blake Oct. 27, 2014, 5:10 p.m. UTC | #1
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>
Marcel Apfelbaum Oct. 27, 2014, 5:15 p.m. UTC | #2
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>
>
Michael S. Tsirkin Oct. 27, 2014, 5:21 p.m. UTC | #3
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>
> > 
> 
>
diff mbox

Patch

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 {