Xen 2015-10-26

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJWLg9iAAoJEIlPj0hw4a6Q+xQP/39Z8+RHWafzaPObXZ285GN2
 w2Nc5kuQlgSU/q+BWYYRnNqc+LN2FNHLGFiDd65pz+uIxgCR6uzvb8IONIctVwPm
 jtYqp3owMG+y0ayVlKfu3YWmED33W63Qn3AyflicPwG+UPIrycTsraNnMbtM4C1/
 f1ZMtPlNekvCsJiBNVPA8ivIMSvFAo9hvbtOURhW28U4hmBy7llmGm3IOPCBLGoI
 V1xoQY7OmquFPxn6h1Rn9Vyiwf/mI2fm9sYJr9emWajmw0UfTdAoPwN0X1uZFcME
 q+VCOBoTFjQOHvXDGIM2eYb+h9Y1DvGHm67dNl/b2EL6EsJZpYCrlxCRPe2GP57C
 wYyeKkW/U/k0wL6QMDRb3Ek43eHpcVjuCDtJipLdLv7JOif4mj1JIZ0sPql1MDdQ
 NPefltrbsFBE/fokOMmacryFGrf6Lk1oyucdGk8vXVthRPMoIaqXQbBUZOdvMZfP
 y7G5t+Llwki1/2IxmZd/dC7jZewXOyNz2oez7v3SQ+F+YmWpXAy3VW+HVefz8Qjg
 8bXTdqHHqFLSyCIMrSFLKWBEeSykXlhqRHEV3RtFaHQGv46kkcAUFzKrv5BcT/4/
 s27V5iU7Lzzy8JSXT2/aNenKD+X7scUtCrVr5gokCsS+3VsKVKkTt2QxHNqZm+JX
 ZNEgEdETTQcPREg/Z61B
 =7yok
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/sstabellini/tags/xen-2015-10-26' into staging

Xen 2015-10-26

# gpg: Signature made Mon 26 Oct 2015 11:32:50 GMT using RSA key ID 70E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"

* remotes/sstabellini/tags/xen-2015-10-26:
  xen-platform: Replace assert() with appropriate error reporting
  xen_platform: switch to realize
  Qemu/Xen: Fix early freeing MSIX MMIO memory region

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-10-26 13:13:38 +00:00
commit 9666248a85
5 changed files with 29 additions and 7 deletions

View File

@ -33,6 +33,7 @@
#include "trace.h" #include "trace.h"
#include "exec/address-spaces.h" #include "exec/address-spaces.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "qemu/error-report.h"
#include <xenguest.h> #include <xenguest.h>
@ -382,13 +383,16 @@ static const VMStateDescription vmstate_xen_platform = {
} }
}; };
static int xen_platform_initfn(PCIDevice *dev) static void xen_platform_realize(PCIDevice *dev, Error **errp)
{ {
PCIXenPlatformState *d = XEN_PLATFORM(dev); PCIXenPlatformState *d = XEN_PLATFORM(dev);
uint8_t *pci_conf; uint8_t *pci_conf;
/* Device will crash on reset if xen is not initialized */ /* Device will crash on reset if xen is not initialized */
assert(xen_enabled()); if (!xen_enabled()) {
error_setg(errp, "xen-platform device requires the Xen accelerator");
return;
}
pci_conf = dev->config; pci_conf = dev->config;
@ -407,8 +411,6 @@ static int xen_platform_initfn(PCIDevice *dev)
&d->mmio_bar); &d->mmio_bar);
platform_fixed_ioport_init(d); platform_fixed_ioport_init(d);
return 0;
} }
static void platform_reset(DeviceState *dev) static void platform_reset(DeviceState *dev)
@ -423,7 +425,7 @@ static void xen_platform_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = xen_platform_initfn; k->realize = xen_platform_realize;
k->vendor_id = PCI_VENDOR_ID_XEN; k->vendor_id = PCI_VENDOR_ID_XEN;
k->device_id = PCI_DEVICE_ID_XEN_PLATFORM; k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80; k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;

View File

@ -938,10 +938,18 @@ static void xen_pci_passthrough_class_init(ObjectClass *klass, void *data)
dc->props = xen_pci_passthrough_properties; dc->props = xen_pci_passthrough_properties;
}; };
static void xen_pci_passthrough_finalize(Object *obj)
{
XenPCIPassthroughState *s = XEN_PT_DEVICE(obj);
xen_pt_msix_delete(s);
}
static const TypeInfo xen_pci_passthrough_info = { static const TypeInfo xen_pci_passthrough_info = {
.name = TYPE_XEN_PT_DEVICE, .name = TYPE_XEN_PT_DEVICE,
.parent = TYPE_PCI_DEVICE, .parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(XenPCIPassthroughState), .instance_size = sizeof(XenPCIPassthroughState),
.instance_finalize = xen_pci_passthrough_finalize,
.class_init = xen_pci_passthrough_class_init, .class_init = xen_pci_passthrough_class_init,
}; };

View File

@ -305,6 +305,7 @@ void xen_pt_msi_disable(XenPCIPassthroughState *s);
int xen_pt_msix_init(XenPCIPassthroughState *s, uint32_t base); int xen_pt_msix_init(XenPCIPassthroughState *s, uint32_t base);
void xen_pt_msix_delete(XenPCIPassthroughState *s); void xen_pt_msix_delete(XenPCIPassthroughState *s);
void xen_pt_msix_unmap(XenPCIPassthroughState *s);
int xen_pt_msix_update(XenPCIPassthroughState *s); int xen_pt_msix_update(XenPCIPassthroughState *s);
int xen_pt_msix_update_remap(XenPCIPassthroughState *s, int bar_index); int xen_pt_msix_update_remap(XenPCIPassthroughState *s, int bar_index);
void xen_pt_msix_disable(XenPCIPassthroughState *s); void xen_pt_msix_disable(XenPCIPassthroughState *s);

View File

@ -2079,7 +2079,7 @@ void xen_pt_config_delete(XenPCIPassthroughState *s)
/* free MSI/MSI-X info table */ /* free MSI/MSI-X info table */
if (s->msix) { if (s->msix) {
xen_pt_msix_delete(s); xen_pt_msix_unmap(s);
} }
g_free(s->msi); g_free(s->msi);

View File

@ -610,7 +610,7 @@ error_out:
return rc; return rc;
} }
void xen_pt_msix_delete(XenPCIPassthroughState *s) void xen_pt_msix_unmap(XenPCIPassthroughState *s)
{ {
XenPTMSIX *msix = s->msix; XenPTMSIX *msix = s->msix;
@ -627,6 +627,17 @@ void xen_pt_msix_delete(XenPCIPassthroughState *s)
} }
memory_region_del_subregion(&s->bar[msix->bar_index], &msix->mmio); memory_region_del_subregion(&s->bar[msix->bar_index], &msix->mmio);
}
void xen_pt_msix_delete(XenPCIPassthroughState *s)
{
XenPTMSIX *msix = s->msix;
if (!msix) {
return;
}
object_unparent(OBJECT(&msix->mmio));
g_free(s->msix); g_free(s->msix);
s->msix = NULL; s->msix = NULL;