]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
ppc: Skip partially initialized vCPUs in 'info pic'
authorGreg Kurz <groug@kaod.org>
Thu, 24 Oct 2019 14:27:33 +0000 (16:27 +0200)
committerLaurent Vivier <lvivier@redhat.com>
Mon, 18 Nov 2019 10:50:25 +0000 (11:50 +0100)
CPU_FOREACH() can race with vCPU hotplug/unplug on sPAPR machines, ie.
we may try to print out info about a vCPU with a NULL presenter pointer.

Check that in order to prevent QEMU from crashing.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157192725327.3146912.12047076483178652551.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
hw/intc/xics.c
hw/intc/xive.c

index 5f746079be46d47dd7b510ab0f6e5b4d1da2883f..e7ac9ba618fa1183629fa0e6e4e3871e4cc29c70 100644 (file)
 
 void icp_pic_print_info(ICPState *icp, Monitor *mon)
 {
-    int cpu_index = icp->cs ? icp->cs->cpu_index : -1;
+    int cpu_index;
+
+    /* Skip partially initialized vCPUs. This can happen on sPAPR when vCPUs
+     * are hot plugged or unplugged.
+     */
+    if (!icp) {
+        return;
+    }
+
+    cpu_index = icp->cs ? icp->cs->cpu_index : -1;
 
     if (!icp->output) {
         return;
index 952a461d5329bda326babb7fe3519e0364a04e2d..75dce82fb205879b5ededbd842fc0fbee8b5401f 100644 (file)
@@ -523,9 +523,18 @@ static const char * const xive_tctx_ring_names[] = {
 
 void xive_tctx_pic_print_info(XiveTCTX *tctx, Monitor *mon)
 {
-    int cpu_index = tctx->cs ? tctx->cs->cpu_index : -1;
+    int cpu_index;
     int i;
 
+    /* Skip partially initialized vCPUs. This can happen on sPAPR when vCPUs
+     * are hot plugged or unplugged.
+     */
+    if (!tctx) {
+        return;
+    }
+
+    cpu_index = tctx->cs ? tctx->cs->cpu_index : -1;
+
     if (kvm_irqchip_in_kernel()) {
         Error *local_err = NULL;