Message ID | 1484859633-24889-1-git-send-email-mst@redhat.com |
---|---|
State | New |
Headers | show |
On 01/19/2017 11:00 PM, Michael S. Tsirkin wrote: > Looks like we didn't mark PCI ROMs as RO allowing > mischief such as guests writing there. > Further, e.g. vhost gets confused trying to allocate > enough space to log writes there. Fix it up. > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > hw/pci/pci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 637d545..eaac185 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -2199,7 +2199,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, > snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev))); > } > pdev->has_rom = true; > - memory_region_init_ram(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); > + memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); > vmstate_register_ram(&pdev->rom, &pdev->qdev); > ptr = memory_region_get_ram_ptr(&pdev->rom); > load_image(path, ptr); > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Thanks, Marcel
On 19/01/2017 22:00, Michael S. Tsirkin wrote: > Looks like we didn't mark PCI ROMs as RO allowing > mischief such as guests writing there. > Further, e.g. vhost gets confused trying to allocate > enough space to log writes there. Fix it up. > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > hw/pci/pci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 637d545..eaac185 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -2199,7 +2199,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, > snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev))); > } > pdev->has_rom = true; > - memory_region_init_ram(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); > + memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); > vmstate_register_ram(&pdev->rom, &pdev->qdev); > ptr = memory_region_get_ram_ptr(&pdev->rom); > load_image(path, ptr); > Tested-by: Laurent Vivier <lvivier@redhat.com>
diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 637d545..eaac185 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2199,7 +2199,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev))); } pdev->has_rom = true; - memory_region_init_ram(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); + memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); vmstate_register_ram(&pdev->rom, &pdev->qdev); ptr = memory_region_get_ram_ptr(&pdev->rom); load_image(path, ptr);
Looks like we didn't mark PCI ROMs as RO allowing mischief such as guests writing there. Further, e.g. vhost gets confused trying to allocate enough space to log writes there. Fix it up. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)