From nobody Sun May 12 08:14:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496943041034515.5818414775354; Thu, 8 Jun 2017 10:30:41 -0700 (PDT) Received: from localhost ([::1]:50807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ1GY-0000YU-K7 for importer@patchew.org; Thu, 08 Jun 2017 13:30:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ1Dr-00074G-0i for qemu-devel@nongnu.org; Thu, 08 Jun 2017 13:27:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJ1Dp-00063n-NA for qemu-devel@nongnu.org; Thu, 08 Jun 2017 13:27:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJ1Dp-00063G-Ei; Thu, 08 Jun 2017 13:27:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69C2589C2A; Thu, 8 Jun 2017 17:27:48 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-117-35.ams2.redhat.com [10.36.117.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C7C07F1C4; Thu, 8 Jun 2017 17:27:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69C2589C2A Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 69C2589C2A From: Laurent Vivier To: David Gibson Date: Thu, 8 Jun 2017 19:27:42 +0200 Message-Id: <20170608172743.10132-2-lvivier@redhat.com> In-Reply-To: <20170608172743.10132-1-lvivier@redhat.com> References: <20170608172743.10132-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 08 Jun 2017 17:27:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] spapr: disable hotplugging without OS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , qemu-devel@nongnu.org, Greg Kurz , Michael Roth , qemu-ppc@nongnu.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the OS is not started, QEMU sends an event to the OS that is lost and cannot be recovered. An unplug is not able to restore QEMU in a coherent state. So, while the OS is not started, disable CPU and memory hotplug. We guess the OS is started if the CAS has been negotiated. Signed-off-by: Laurent Vivier Tested-by: Daniel Barboza --- hw/ppc/spapr.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++= +--- hw/ppc/spapr_hcall.c | 1 + include/hw/ppc/spapr.h | 2 ++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 91b4057..4c979d5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1308,6 +1308,7 @@ static void ppc_spapr_reset(void) { MachineState *machine =3D MACHINE(qdev_get_machine()); sPAPRMachineState *spapr =3D SPAPR_MACHINE(machine); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); PowerPCCPU *first_ppc_cpu; uint32_t rtas_limit; hwaddr rtas_addr, fdt_addr; @@ -1373,6 +1374,7 @@ static void ppc_spapr_reset(void) first_ppc_cpu->env.nip =3D SPAPR_ENTRY_POINT; =20 spapr->cas_reboot =3D false; + spapr->cas_completed =3D smc->cas_completed_default; } =20 static void spapr_create_nvram(sPAPRMachineState *spapr) @@ -1528,6 +1530,27 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +static bool spapr_cas_completed_needed(void *opaque) +{ + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(opaque); + + /* we need to migrate cas_completed only if it is + * not set by default + */ + return !smc->cas_completed_default; +} + +static const VMStateDescription vmstate_spapr_cas_completed =3D { + .name =3D "spapr_cas_completed", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_cas_completed_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BOOL(cas_completed, sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, @@ -1546,6 +1569,7 @@ static const VMStateDescription vmstate_spapr =3D { .subsections =3D (const VMStateDescription*[]) { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, + &vmstate_spapr_cas_completed, NULL } }; @@ -2599,6 +2623,7 @@ out: static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) { + sPAPRMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr =3D ddc->get_memory_region(dimm); @@ -2617,6 +2642,14 @@ static void spapr_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, "Use 'memory-backend-file' with correct mem-path."); return; } + if (dev->hotplugged) { + if (!runstate_check(RUN_STATE_PRELAUNCH) && + !runstate_check(RUN_STATE_INMIGRATE) && + !ms->cas_completed) { + error_setg(errp, "Memory hotplug not supported without OS"); + return; + } + } } =20 struct sPAPRDIMMState { @@ -2915,6 +2948,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, Error **errp) { MachineState *machine =3D MACHINE(OBJECT(hotplug_dev)); + sPAPRMachineState *ms =3D SPAPR_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); Error *local_err =3D NULL; CPUCore *cc =3D CPU_CORE(dev); @@ -2923,9 +2957,18 @@ static void spapr_core_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, CPUArchId *core_slot; int index; =20 - if (dev->hotplugged && !mc->has_hotpluggable_cpus) { - error_setg(&local_err, "CPU hotplug not supported for this machine= "); - goto out; + if (dev->hotplugged) { + if (!mc->has_hotpluggable_cpus) { + error_setg(&local_err, + "CPU hotplug not supported for this machine"); + goto out; + } + if (!runstate_check(RUN_STATE_PRELAUNCH) && + !runstate_check(RUN_STATE_INMIGRATE) && + !ms->cas_completed) { + error_setg(&local_err, "CPU hotplug not supported without OS"); + goto out; + } } =20 if (strcmp(base_core_type, type)) { @@ -3358,9 +3401,11 @@ static void spapr_machine_2_9_instance_options(Machi= neState *machine) =20 static void spapr_machine_2_9_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); spapr_machine_2_10_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_9); mc->numa_auto_assign_ram =3D numa_legacy_auto_assign_ram; + smc->cas_completed_default =3D true; } =20 DEFINE_SPAPR_MACHINE(2_9, "2.9", false); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index aa1ffea..d561a00 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1185,6 +1185,7 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu, } } =20 + spapr->cas_completed =3D true; return H_SUCCESS; } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index f973b02..f5835db 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -57,6 +57,7 @@ struct sPAPRMachineClass { uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64, unsigned n_dma, uint32_t *liobns, Error **errp); + bool cas_completed_default; }; =20 /** @@ -90,6 +91,7 @@ struct sPAPRMachineState { sPAPROptionVector *ov5_cas; /* negotiated (via CAS) option vectors= */ bool cas_reboot; bool cas_legacy_guest_workaround; + bool cas_completed; =20 Notifier epow_notifier; QTAILQ_HEAD(, sPAPREventLogEntry) pending_events; --=20 2.9.4 From nobody Sun May 12 08:14:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149694298182085.01589038794714; Thu, 8 Jun 2017 10:29:41 -0700 (PDT) Received: from localhost ([::1]:50796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ1Fb-0008DG-0t for importer@patchew.org; Thu, 08 Jun 2017 13:29:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ1Dt-00075s-97 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 13:27:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJ1Ds-00064i-1j for qemu-devel@nongnu.org; Thu, 08 Jun 2017 13:27:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJ1Dr-00064O-PU; Thu, 08 Jun 2017 13:27:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B69AF79706; Thu, 8 Jun 2017 17:27:50 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-117-35.ams2.redhat.com [10.36.117.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAF817F1C3; Thu, 8 Jun 2017 17:27:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B69AF79706 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B69AF79706 From: Laurent Vivier To: David Gibson Date: Thu, 8 Jun 2017 19:27:43 +0200 Message-Id: <20170608172743.10132-3-lvivier@redhat.com> In-Reply-To: <20170608172743.10132-1-lvivier@redhat.com> References: <20170608172743.10132-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 08 Jun 2017 17:27:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] Revert "spapr: fix memory hot-unplugging" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , qemu-devel@nongnu.org, Greg Kurz , Michael Roth , qemu-ppc@nongnu.org, Daniel Henrique Barboza Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This reverts commit fe6824d12642b005c69123ecf8631f9b13553f8b. Conflicts hw/ppc/spapr_drc.c, because get_index() has been renamed spapr_get_index(). This didn't fix the problem. Once the hotplug has been started some memory is allocated and some structures are allocated. We don't free it when we ignore the unplug, and we can't because they can be in use by the kernel. Signed-off-by: Laurent Vivier Tested-by: Daniel Barboza --- hw/ppc/spapr_drc.c | 20 +++----------------- include/hw/ppc/spapr_drc.h | 1 - 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 39e7f30..7605977 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -140,17 +140,6 @@ static uint32_t set_allocation_state(sPAPRDRConnector = *drc, if (!drc->dev) { return RTAS_OUT_NO_SUCH_INDICATOR; } - if (drc->awaiting_release && drc->awaiting_allocation) { - /* kernel is acknowledging a previous hotplug event - * while we are already removing it. - * it's safe to ignore awaiting_allocation here since we know = the - * situation is predicated on the guest either already having = done - * so (boot-time hotplug), or never being able to acquire in t= he - * first place (hotplug followed by immediate unplug). - */ - drc->awaiting_allocation_skippable =3D true; - return RTAS_OUT_NO_SUCH_INDICATOR; - } } =20 if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { @@ -401,11 +390,9 @@ static void detach(sPAPRDRConnector *drc, DeviceState = *d, Error **errp) } =20 if (drc->awaiting_allocation) { - if (!drc->awaiting_allocation_skippable) { - drc->awaiting_release =3D true; - trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); - return; - } + drc->awaiting_release =3D true; + trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); + return; } =20 drc->indicator_state =3D SPAPR_DR_INDICATOR_STATE_INACTIVE; @@ -428,7 +415,6 @@ static void detach(sPAPRDRConnector *drc, DeviceState *= d, Error **errp) } =20 drc->awaiting_release =3D false; - drc->awaiting_allocation_skippable =3D false; g_free(drc->fdt); drc->fdt =3D NULL; drc->fdt_start_offset =3D 0; diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index c88e1be..84b58f0 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -200,7 +200,6 @@ typedef struct sPAPRDRConnector { bool awaiting_release; bool signalled; bool awaiting_allocation; - bool awaiting_allocation_skippable; =20 /* device pointer, via link property */ DeviceState *dev; --=20 2.9.4