Skip to contentSkip to conversation

Xen emulation build/Coverity fixes

PATCH In review David Woodhouse 4 participants 17 messages Apr 12, 2023 – Apr 17, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Xen emulation build/Coverity fixes

Some Coverity fixes and minor cleanups. And most notably, dropping support for Xen libraries older than 4.7.1.

I believe there are two issues that remain to be fixed. The x32 build fails, and I've seen patches which attempt to detect x32 and disable the Xen emulation. Along with assertions that we just shouldn't care. I don't have a strong opinion either way but it seems to be in hand.

The other is the question of what Xen *actually* does if you try to unmap an IRQ_MSI_EMU PIRQ. I don't think Linux guests try that, and I'm fairly sure Windows doesn't even use MSI→PIRQ mappings in the first place, and I doubt any other guests care either. I'd like to establish the 'correct' behaviour and implement it, ideally before the 8.0 release, but it's going to take me a few days more.

David Woodhouse (5):
hw/xen: Simplify emulated Xen platform init hw/xen: Fix memory leak in libxenstore_open() for Xen
xen: Drop support for Xen versions below 4.7.1 hw/xen: Fix double-free in xen_console store_con_info() hw/xen: Fix broken check for invalid state in xs_be_open()

 hw/char/xen_console.c       |  13 ++----
 hw/i386/kvm/xen_evtchn.c    |  40 ++++++++---------
 hw/i386/kvm/xen_evtchn.h    |   3 +-
 hw/i386/kvm/xen_xenstore.c  |   2 +-
 hw/i386/pc.c                |  13 ++----
 hw/xen/xen-operations.c     |  59 +-----------------------
 include/hw/xen/xen_native.h | 107 +-------------------------------------------
 meson.build                 |   5 +--
 scripts/xen-detect.c        |  60 -------------------------
 9 files changed, 33 insertions(+), 269 deletions(-)
#1 lore raw

PATCH 1/5 hw/xen: Simplify emulated Xen platform init

From: David Woodhouse <[email protected]>

I initially put the basic platform init (overlay pages, grant tables, event channels) into mc->kvm_type because that was the earliest place that could sensibly test for xen_mode==XEN_EMULATE.

The intent was to do this early enough that we could then initialise the XenBus and other parts which would have depended on them, from a generic location for both Xen and KVM/Xen in the PC-specific code, as seen in
https://lore.kernel.org/qemu-devel/[email protected]/

However, then the Xen on Arm patches came along, and *they* wanted to do the XenBus init from a 'generic' Xen-specific location instead:
https://lore.kernel.org/qemu-devel/[email protected]/

Since there's no generic location that covers all three, I conceded to do it for XEN_EMULATE mode in pc_basic_devices_init().

And now there's absolutely no point in having some of the platform init done from pc_machine_kvm_type(); we can move it all up to live in a single place in pc_basic_devices_init(). This has the added benefit that we can drop the separate xen_evtchn_connect_gsis() function completely, and pass just the system GSIs in directly to xen_evtchn_create().

While I'm at it, it does no harm to explicitly pass in the *number* of said GSIs, because it does make me twitch a bit to pass an array of impicit size. During the lifetime of the KVM/Xen patchset, that had already changed (albeit just cosmetically) from GSI_NUM_PINS to IOAPIC_NUM_PINS.

And document a bit better that this is for the *output* GSI for raising CPU0's events when the per-CPU vector isn't available. The fact that we create a whole set of them and then only waggle the one we're told to, instead of having a single output and only *connecting* it to the GSI that it should be connected to, is still non-intuitive for me.

---
 hw/i386/kvm/xen_evtchn.c | 40 ++++++++++++++++++++--------------------
 hw/i386/kvm/xen_evtchn.h |  3 +--
 hw/i386/pc.c             | 13 ++++---------
 3 files changed, 25 insertions(+), 31 deletions(-)
hw/i386/kvm/xen_evtchn.c +20 -20
index 3048329474..3d810dbd59 100644
@@ -147,7 +147,10 @@ struct XenEvtchnState {
     QemuMutex port_lock;
     uint32_t nr_ports;
     XenEvtchnPort port_table[EVTCHN_2L_NR_CHANNELS];
-    qemu_irq gsis[IOAPIC_NUM_PINS];
+
+    /* Connected to the system GSIs for raising callback as GSI / INTx */
+    unsigned int nr_callback_gsis;
+    qemu_irq *callback_gsis;
 
     struct xenevtchn_handle *be_handles[EVTCHN_2L_NR_CHANNELS];
 
@@ -299,7 +302,7 @@ static void gsi_assert_bh(void *opaque)
     }
 }
 
-void xen_evtchn_create(void)
+void xen_evtchn_create(unsigned int nr_gsis, qemu_irq *system_gsis)
 {
     XenEvtchnState *s = XEN_EVTCHN(sysbus_create_simple(TYPE_XEN_EVTCHN,
                                                         -1, NULL));
@@ -310,8 +313,19 @@ void xen_evtchn_create(void)
     qemu_mutex_init(&s->port_lock);
     s->gsi_bh = aio_bh_new(qemu_get_aio_context(), gsi_assert_bh, s);
 
-    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
-        sysbus_init_irq(SYS_BUS_DEVICE(s), &s->gsis[i]);
+    /*
+     * These are the *output* GSI from event channel support, for
+     * signalling CPU0's events via GSI or PCI INTx instead of the
+     * per-CPU vector. We create a *set* of irqs and connect one to
+     * each of the system GSIs which were passed in from the platform
+     * code, and then just trigger the right one as appropriate from
+     * xen_evtchn_set_callback_level().
+     */
+    s->nr_callback_gsis = nr_gsis;
+    s->callback_gsis = g_new0(qemu_irq, nr_gsis);
+    for (i = 0; i < nr_gsis; i++) {
+        sysbus_init_irq(SYS_BUS_DEVICE(s), &s->callback_gsis[i]);
+        sysbus_connect_irq(SYS_BUS_DEVICE(s), i, system_gsis[i]);
     }
 
     /*
@@ -336,20 +350,6 @@ void xen_evtchn_create(void)
     xen_evtchn_ops = &emu_evtchn_backend_ops;
 }
 
-void xen_evtchn_connect_gsis(qemu_irq *system_gsis)
-{
-    XenEvtchnState *s = xen_evtchn_singleton;
-    int i;
-
-    if (!s) {
-        return;
-    }
-
-    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
-        sysbus_connect_irq(SYS_BUS_DEVICE(s), i, system_gsis[i]);
-    }
-}
-
 static void xen_evtchn_register_types(void)
 {
     type_register_static(&xen_evtchn_info);
@@ -430,8 +430,8 @@ void xen_evtchn_set_callback_level(int level)
         return;
     }
 
-    if (s->callback_gsi && s->callback_gsi < IOAPIC_NUM_PINS) {
-        qemu_set_irq(s->gsis[s->callback_gsi], level);
+    if (s->callback_gsi && s->callback_gsi < s->nr_callback_gsis) {
+        qemu_set_irq(s->callback_gsis[s->callback_gsi], level);
         if (level) {
             /* Ensure the vCPU polls for deassertion */
             kvm_xen_set_callback_asserted();
hw/i386/kvm/xen_evtchn.h +1 -2
index bfb67ac2bc..b740acfc0d 100644
@@ -16,10 +16,9 @@
 
 typedef uint32_t evtchn_port_t;
 
-void xen_evtchn_create(void);
+void xen_evtchn_create(unsigned int nr_gsis, qemu_irq *system_gsis);
 int xen_evtchn_soft_reset(void);
 int xen_evtchn_set_callback_param(uint64_t param);
-void xen_evtchn_connect_gsis(qemu_irq *system_gsis);
 void xen_evtchn_set_callback_level(int level);
 
 int xen_evtchn_set_port(uint16_t port);
hw/i386/pc.c +4 -9
index 1489abf010..25584cb8f3 100644
@@ -1319,7 +1319,10 @@ void pc_basic_device_init(struct PCMachineState *pcms,
 
 #ifdef CONFIG_XEN_EMU
     if (xen_mode == XEN_EMULATE) {
-        xen_evtchn_connect_gsis(gsi);
+        xen_overlay_create();
+        xen_evtchn_create(IOAPIC_NUM_PINS, gsi);
+        xen_gnttab_create();
+        xen_xenstore_create();
         if (pcms->bus) {
             pci_create_simple(pcms->bus, -1, "xen-platform");
         }
@@ -1868,14 +1871,6 @@ static void pc_machine_initfn(Object *obj)
 
 int pc_machine_kvm_type(MachineState *machine, const char *kvm_type)
 {
-#ifdef CONFIG_XEN_EMU
-    if (xen_mode == XEN_EMULATE) {
-        xen_overlay_create();
-        xen_evtchn_create();
-        xen_gnttab_create();
-        xen_xenstore_create();
-    }
-#endif
     return 0;
 }
 
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/5 hw/xen: Fix memory leak in libxenstore_open() for Xen

In reply to David Woodhouse

From: David Woodhouse <[email protected]>

There was a superfluous allocation of the XS handle, leading to it being leaked on both the error path and the success path (where it gets allocated again).

Spotted by Coverity (CID 1508098).

Fixes ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirection to internal emulation")
---
 hw/xen/xen-operations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xen/xen-operations.c +1 -1
index 4b78fbf4bd..3d213d28df 100644
@@ -287,7 +287,7 @@ static void watch_event(void *opaque)
 static struct qemu_xs_handle *libxenstore_open(void)
 {
     struct xs_handle *xsh = xs_open(0);
-    struct qemu_xs_handle *h = g_new0(struct qemu_xs_handle, 1);
+    struct qemu_xs_handle *h;
 
     if (!xsh) {
         return NULL;
Signature · 1 line
2.39.2
Reviewed-by on v1 2/5
#3 lore raw

Re: [PATCH 2/5] hw/xen: Fix memory leak in libxenstore_open() for Xen

Quoted 6 lines · David Woodhouse

From: David Woodhouse <[email protected]>

There was a superfluous allocation of the XS handle, leading to it being leaked on both the error path and the success path (where it gets allocated again).

Quoted 6 lines

Spotted by Coverity (CID 1508098).

Fixes ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirection to internal emulation")
#4 lore raw

PATCH 3/5 xen: Drop support for Xen versions below 4.7.1

In reply to David Woodhouse

From: David Woodhouse <[email protected]>

In restructuring to allow for internal emulation of Xen functionality, I broke compatibility for Xen 4.6 and earlier. Fix this by explicitly removing support for anything older than 4.7.1, which is also ancient but it does still build, and the compatibility support for it is fairly unintrusive.

Fixes 15e283c5b684 ("hw/xen: Add foreignmem operations to allow redirection to internal emulation")
---
 hw/xen/xen-operations.c     |  57 +------------------
 include/hw/xen/xen_native.h | 107 +-----------------------------------
 meson.build                 |   5 +-
 scripts/xen-detect.c        |  60 --------------------
 4 files changed, 3 insertions(+), 226 deletions(-)
hw/xen/xen-operations.c +1 -56
index 3d213d28df..e00983ec44 100644
@@ -28,46 +28,13 @@
 #include <xenctrl.h>
 
 /*
- * We don't support Xen prior to 4.2.0.
+ * We don't support Xen prior to 4.7.1.
  */
 
-/* Xen 4.2 through 4.6 */
-#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40701
-
-typedef xc_evtchn xenevtchn_handle;
-typedef evtchn_port_or_error_t xenevtchn_port_or_error_t;
-
-#define xenevtchn_open(l, f) xc_evtchn_open(l, f);
-#define xenevtchn_close(h) xc_evtchn_close(h)
-#define xenevtchn_fd(h) xc_evtchn_fd(h)
-#define xenevtchn_pending(h) xc_evtchn_pending(h)
-#define xenevtchn_notify(h, p) xc_evtchn_notify(h, p)
-#define xenevtchn_bind_interdomain(h, d, p) xc_evtchn_bind_interdomain(h, d, p)
-#define xenevtchn_unmask(h, p) xc_evtchn_unmask(h, p)
-#define xenevtchn_unbind(h, p) xc_evtchn_unbind(h, p)
-
-typedef xc_gnttab xengnttab_handle;
-
-#define xengnttab_open(l, f) xc_gnttab_open(l, f)
-#define xengnttab_close(h) xc_gnttab_close(h)
-#define xengnttab_set_max_grants(h, n) xc_gnttab_set_max_grants(h, n)
-#define xengnttab_map_grant_ref(h, d, r, p) xc_gnttab_map_grant_ref(h, d, r, p)
-#define xengnttab_unmap(h, a, n) xc_gnttab_munmap(h, a, n)
-#define xengnttab_map_grant_refs(h, c, d, r, p) \
-    xc_gnttab_map_grant_refs(h, c, d, r, p)
-#define xengnttab_map_domain_grant_refs(h, c, d, r, p) \
-    xc_gnttab_map_domain_grant_refs(h, c, d, r, p)
-
-typedef xc_interface xenforeignmemory_handle;
-
-#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40701 */
-
 #include <xenevtchn.h>
 #include <xengnttab.h>
 #include <xenforeignmemory.h>
 
-#endif
-
 /* Xen before 4.8 */
 
 static int libxengnttab_fallback_grant_copy(xengnttab_handle *xgt,
@@ -223,26 +190,6 @@ static struct gnttab_backend_ops libxengnttab_backend_ops = {
     .unmap = libxengnttab_backend_unmap,
 };
 
-#if CONFIG_XEN_CTRL_INTERFACE_VERSION < 40701
-
-static void *libxenforeignmem_backend_map(uint32_t dom, void *addr, int prot,
-                                          size_t pages, xfn_pfn_t *pfns,
-                                          int *errs)
-{
-    if (errs) {
-        return xc_map_foreign_bulk(xen_xc, dom, prot, pfns, errs, pages);
-    } else {
-        return xc_map_foreign_pages(xen_xc, dom, prot, pfns, pages);
-    }
-}
-
-static int libxenforeignmem_backend_unmap(void *addr, size_t pages)
-{
-    return munmap(addr, pages * XC_PAGE_SIZE);
-}
-
-#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40701 */
-
 static void *libxenforeignmem_backend_map(uint32_t dom, void *addr, int prot,
                                           size_t pages, xen_pfn_t *pfns,
                                           int *errs)
@@ -256,8 +203,6 @@ static int libxenforeignmem_backend_unmap(void *addr, size_t pages)
     return xenforeignmemory_unmap(xen_fmem, addr, pages);
 }
 
-#endif
-
 struct foreignmem_backend_ops libxenforeignmem_backend_ops = {
     .map = libxenforeignmem_backend_map,
     .unmap = libxenforeignmem_backend_unmap,
include/hw/xen/xen_native.h +1 -106

145 lines not on this page · raw message

meson.build +1 -4
index c44d05a13f..1f223ae7fc 100644
@@ -1425,16 +1425,13 @@ if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
     endif
   endif
   if not xen.found()
-    xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1', '4.6.0', '4.5.0', '4.2.0' ]
+    xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
     xen_libs = {
       '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
       '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
       '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
       '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
       '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
-      '4.6.0': [ 'xenstore', 'xenctrl' ],
-      '4.5.0': [ 'xenstore', 'xenctrl' ],
-      '4.2.0': [ 'xenstore', 'xenctrl' ],
     }
     xen_deps = {}
     foreach ver: xen_tests
scripts/xen-detect.c +0 -60

66 lines not on this page · raw message

Signature · 1 line
2.39.2
Reviewed-by on v1 3/5
#5 lore raw

Re: [PATCH 3/5] xen: Drop support for Xen versions below 4.7.1

Quoted 8 lines · David Woodhouse

From: David Woodhouse <[email protected]>

In restructuring to allow for internal emulation of Xen functionality, I broke compatibility for Xen 4.6 and earlier. Fix this by explicitly removing support for anything older than 4.7.1, which is also ancient but it does still build, and the compatibility support for it is fairly unintrusive.

Quoted 9 lines
Fixes 15e283c5b684 ("hw/xen: Add foreignmem operations to allow redirection to internal emulation")
---
  hw/xen/xen-operations.c     |  57 +------------------
  include/hw/xen/xen_native.h | 107 +-----------------------------------
  meson.build                 |   5 +-
  scripts/xen-detect.c        |  60 --------------------
  4 files changed, 3 insertions(+), 226 deletions(-)
#6 lore raw

PATCH 4/5 hw/xen: Fix double-free in xen_console store_con_info()

In reply to David Woodhouse

From: David Woodhouse <[email protected]>

Coverity spotted a double-free (CID 1508254); we g_string_free(path) and then for some reason immediately call free(path) too.

We should just use g_autoptr() for it anyway, which simplifies the code a bit.

Fixes 7a8a749da7d3 ("hw/xen: Move xenstore_store_pv_console_info to xen_console.c")
---
 hw/char/xen_console.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
hw/char/xen_console.c +3 -10
index c7a19c0e7c..810dae3f44 100644
@@ -178,8 +178,7 @@ static int store_con_info(struct XenConsole *con)
     Chardev *cs = qemu_chr_fe_get_driver(&con->chr);
     char *pts = NULL;
     char *dom_path;
-    GString *path;
-    int ret = -1;
+    g_autoptr(GString) path = NULL;
 
     /* Only continue if we're talking to a pty. */
     if (!CHARDEV_IS_PTY(cs)) {
@@ -204,15 +203,9 @@ static int store_con_info(struct XenConsole *con)
 
     if (xenstore_write_str(con->console, path->str, pts)) {
         fprintf(stderr, "xenstore_write_str for '%s' fail", path->str);
-        goto out;
+        return -1;
     }
-    ret = 0;
-
-out:
-    g_string_free(path, true);
-    free(path);
-
-    return ret;
+    return 0;
 }
 
 static int con_init(struct XenLegacyDevice *xendev)
Signature · 1 line
2.39.2
Reviewed-by on v1 4/5
#7 lore raw

Re: [PATCH 4/5] hw/xen: Fix double-free in xen_console store_con_info()

Quoted 11 lines · David Woodhouse

From: David Woodhouse <[email protected]>

Coverity spotted a double-free (CID 1508254); we g_string_free(path) and then for some reason immediately call free(path) too.

We should just use g_autoptr() for it anyway, which simplifies the code a bit.

Fixes 7a8a749da7d3 ("hw/xen: Move xenstore_store_pv_console_info to xen_console.c")

thanks
-- PMM

Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] hw/xen: Fix double-free in xen_console store_con_info()

In reply to David Woodhouse
Quoted 5 lines · David Woodhouse

From: David Woodhouse <[email protected]>

Coverity spotted a double-free (CID 1508254); we g_string_free(path) and then for some reason immediately call free(path) too.

Quoted 9 lines

We should just use g_autoptr() for it anyway, which simplifies the code a bit.

Fixes 7a8a749da7d3 ("hw/xen: Move xenstore_store_pv_console_info to xen_console.c")
---
  hw/char/xen_console.c | 13 +++----------
  1 file changed, 3 insertions(+), 10 deletions(-)
#9 lore raw

PATCH 5/5 hw/xen: Fix broken check for invalid state in xs_be_open()

In reply to David Woodhouse

From: David Woodhouse <[email protected]>

Coverity points out that if (!s && !s->impl) isn't really what we intended to do here. CID 1508131.

Fixes 032475127225 ("hw/xen: Add emulated implementation of XenStore operations")
---
 hw/i386/kvm/xen_xenstore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/kvm/xen_xenstore.c +1 -1
index 900679af8a..65f91e87d7 100644
@@ -1688,7 +1688,7 @@ static struct qemu_xs_handle *xs_be_open(void)
     XenXenstoreState *s = xen_xenstore_singleton;
     struct qemu_xs_handle *h;
 
-    if (!s && !s->impl) {
+    if (!s || !s->impl) {
         errno = -ENOSYS;
         return NULL;
     }
Signature · 1 line
2.39.2
Reviewed-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] hw/xen: Fix broken check for invalid state in xs_be_open()

Quoted 9 lines · David Woodhouse

From: David Woodhouse <[email protected]>

Coverity points out that if (!s && !s->impl) isn't really what we intended to do here. CID 1508131.

Fixes 032475127225 ("hw/xen: Add emulated implementation of XenStore operations")

---

thanks
-- PMM

Reviewed-by on v1 5/5
#11 lore raw

Re: [PATCH 5/5] hw/xen: Fix broken check for invalid state in xs_be_open()

In reply to David Woodhouse
Quoted 11 lines · David Woodhouse

From: David Woodhouse <[email protected]>

Coverity points out that if (!s && !s->impl) isn't really what we intended to do here. CID 1508131.

Fixes 032475127225 ("hw/xen: Add emulated implementation of XenStore operations")
---
  hw/i386/kvm/xen_xenstore.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
#12 lore raw
In reply to David Woodhouse
Quoted 16 lines · David Woodhouse

Some Coverity fixes and minor cleanups. And most notably, dropping support for Xen libraries older than 4.7.1.

I believe there are two issues that remain to be fixed. The x32 build fails, and I've seen patches which attempt to detect x32 and disable the Xen emulation. Along with assertions that we just shouldn't care. I don't have a strong opinion either way but it seems to be in hand.

The other is the question of what Xen *actually* does if you try to unmap an IRQ_MSI_EMU PIRQ. I don't think Linux guests try that, and I'm fairly sure Windows doesn't even use MSI→PIRQ mappings in the first place, and I doubt any other guests care either. I'd like to establish the 'correct' behaviour and implement it, ideally before the 8.0 release, but it's going to take me a few days more.

Quoted 7 lines

David Woodhouse (5):
hw/xen: Simplify emulated Xen platform init hw/xen: Fix memory leak in libxenstore_open() for Xen
xen: Drop support for Xen versions below 4.7.1 hw/xen: Fix double-free in xen_console store_con_info() hw/xen: Fix broken check for invalid state in xs_be_open()

This is highly unlikely to make 8.0 at this point, FYI. If there's anything in this you think is super-critical we might be able to sneak it in.

thanks
-- PMM

#13 lore raw
Quoted 25 lines · Peter Maydell
Quoted 16 lines · David Woodhouse

Some Coverity fixes and minor cleanups. And most notably, dropping support for Xen libraries older than 4.7.1.

I believe there are two issues that remain to be fixed. The x32 build fails, and I've seen patches which attempt to detect x32 and disable the Xen emulation. Along with assertions that we just shouldn't care. I don't have a strong opinion either way but it seems to be in hand.

The other is the question of what Xen *actually* does if you try to unmap an IRQ_MSI_EMU PIRQ. I don't think Linux guests try that, and I'm fairly sure Windows doesn't even use MSI→PIRQ mappings in the first place, and I doubt any other guests care either. I'd like to establish the 'correct' behaviour and implement it, ideally before the 8.0 release, but it's going to take me a few days more.

Quoted 7 lines

David Woodhouse (5):
      hw/xen: Simplify emulated Xen platform init hw/xen: Fix memory leak in libxenstore_open() for Xen
      xen: Drop support for Xen versions below 4.7.1 hw/xen: Fix double-free in xen_console store_con_info() hw/xen: Fix broken check for invalid state in xs_be_open()

Quoted 3 lines

This is highly unlikely to make 8.0 at this point, FYI. If there's anything in this you think is super-critical we might be able to sneak it in.

Nothing is super-critical except maybe the double-free in store_con_info(). That could lead to a crash on startup if the QEMU Xen console is being used.

#14 lore raw
Quoted 26 lines · David Woodhouse
Quoted 25 lines · Peter Maydell
Quoted 23 lines · David Woodhouse

Some Coverity fixes and minor cleanups. And most notably, dropping support for Xen libraries older than 4.7.1.

I believe there are two issues that remain to be fixed. The x32 build fails, and I've seen patches which attempt to detect x32 and disable the Xen emulation. Along with assertions that we just shouldn't care. I don't have a strong opinion either way but it seems to be in hand.

The other is the question of what Xen *actually* does if you try to unmap an IRQ_MSI_EMU PIRQ. I don't think Linux guests try that, and I'm fairly sure Windows doesn't even use MSI→PIRQ mappings in the first place, and I doubt any other guests care either. I'd like to establish the 'correct' behaviour and implement it, ideally before the 8.0 release, but it's going to take me a few days more.

David Woodhouse (5):
      hw/xen: Simplify emulated Xen platform init hw/xen: Fix memory leak in libxenstore_open() for Xen
      xen: Drop support for Xen versions below 4.7.1 hw/xen: Fix double-free in xen_console store_con_info() hw/xen: Fix broken check for invalid state in xs_be_open()

Quoted 7 lines
Quoted 3 lines

This is highly unlikely to make 8.0 at this point, FYI. If there's anything in this you think is super-critical we might be able to sneak it in.

Nothing is super-critical except maybe the double-free in store_con_info(). That could lead to a crash on startup if the QEMU Xen console is being used.

Although we could just do the one-liner that drops the extra 'free' instead of converting to g_autoptr.

#15 lore raw
In reply to David Woodhouse
Quoted 27 lines · David Woodhouse
Quoted 25 lines · Peter Maydell
Quoted 23 lines · David Woodhouse

Some Coverity fixes and minor cleanups. And most notably, dropping support for Xen libraries older than 4.7.1.

I believe there are two issues that remain to be fixed. The x32 build fails, and I've seen patches which attempt to detect x32 and disable the Xen emulation. Along with assertions that we just shouldn't care. I don't have a strong opinion either way but it seems to be in hand.

The other is the question of what Xen *actually* does if you try to unmap an IRQ_MSI_EMU PIRQ. I don't think Linux guests try that, and I'm fairly sure Windows doesn't even use MSI→PIRQ mappings in the first place, and I doubt any other guests care either. I'd like to establish the 'correct' behaviour and implement it, ideally before the 8.0 release, but it's going to take me a few days more.

David Woodhouse (5):
hw/xen: Simplify emulated Xen platform init hw/xen: Fix memory leak in libxenstore_open() for Xen
xen: Drop support for Xen versions below 4.7.1 hw/xen: Fix double-free in xen_console store_con_info() hw/xen: Fix broken check for invalid state in xs_be_open()

Quoted 7 lines
Quoted 3 lines

This is highly unlikely to make 8.0 at this point, FYI. If there's anything in this you think is super-critical we might be able to sneak it in.

Nothing is super-critical except maybe the double-free in store_con_info(). That could lead to a crash on startup if the QEMU Xen console is being used.

I've cherry-picked that double-free patch to apply for 8.0; thanks.

-- PMM