Commit 0a83b470 authored by Greg Kurz's avatar Greg Kurz Committed by Laurent Vivier
Browse files

ppc: Skip partially initialized vCPUs in 'info pic'



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: default avatarGreg Kurz <groug@kaod.org>
Message-Id: <157192725327.3146912.12047076483178652551.stgit@bahia.lan>
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarLaurent Vivier <lvivier@redhat.com>
parent 35886de1
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -44,7 +44,16 @@

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;
+10 −1
Original line number Diff line number Diff line
@@ -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;