From nobody Sun Apr 28 00:02:05 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 1495539271587521.3550172538589; Tue, 23 May 2017 04:34:31 -0700 (PDT) Received: from localhost ([::1]:47835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD857-0000ss-46 for importer@patchew.org; Tue, 23 May 2017 07:34:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD7pW-0003lZ-5j for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD7pS-0006AL-P9 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dD7pS-00069o-Fs; Tue, 23 May 2017 07:18:18 -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 79DEA61D22; Tue, 23 May 2017 11:18:17 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-216.ams2.redhat.com [10.36.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id E75E17FCD6; Tue, 23 May 2017 11:18:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79DEA61D22 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 79DEA61D22 From: Laurent Vivier To: David Gibson Date: Tue, 23 May 2017 13:18:09 +0200 Message-Id: <20170523111812.13469-2-lvivier@redhat.com> In-Reply-To: <20170523111812.13469-1-lvivier@redhat.com> References: <20170523111812.13469-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.39]); Tue, 23 May 2017 11:18:17 +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 1/4] spapr: add pre_plug function for memory 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-ppc@nongnu.org, qemu-devel@nongnu.org, Michael Roth 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 allows to manage errors before the memory has started to be hotplugged. We already have the function for the CPU cores. Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0980d73..0e8d8d1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2569,20 +2569,6 @@ static void spapr_memory_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, uint64_t align =3D memory_region_get_alignment(mr); uint64_t size =3D memory_region_size(mr); uint64_t addr; - char *mem_dev; - - if (size % SPAPR_MEMORY_BLOCK_SIZE) { - error_setg(&local_err, "Hotplugged memory size must be a multiple = of " - "%lld MB", SPAPR_MEMORY_BLOCK_SIZE/M_BYTE); - goto out; - } - - mem_dev =3D object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP,= NULL); - if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { - error_setg(&local_err, "Memory backend has bad page size. " - "Use 'memory-backend-file' with correct mem-path."); - goto out; - } =20 pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err); if (local_err) { @@ -2603,6 +2589,33 @@ out: error_propagate(errp, local_err); } =20 +static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, + Error **errp) +{ + PCDIMMDevice *dimm =3D PC_DIMM(dev); + PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); + MemoryRegion *mr =3D ddc->get_memory_region(dimm); + uint64_t size =3D memory_region_size(mr); + Error *local_err =3D NULL; + char *mem_dev; + + if (size % SPAPR_MEMORY_BLOCK_SIZE) { + error_setg(&local_err, "Hotplugged memory size must be a multiple = of " + "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE); + goto out; + } + + mem_dev =3D object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP,= NULL); + if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { + error_setg(&local_err, "Memory backend has bad page size. " + "Use 'memory-backend-file' with correct mem-path."); + goto out; + } + +out: + error_propagate(errp, local_err); +} + typedef struct sPAPRDIMMState { uint32_t nr_lmbs; } sPAPRDIMMState; @@ -2990,7 +3003,9 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + spapr_memory_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_pre_plug(hotplug_dev, dev, errp); } } --=20 2.9.4 From nobody Sun Apr 28 00:02:05 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 1495539435421657.3810628963108; Tue, 23 May 2017 04:37:15 -0700 (PDT) Received: from localhost ([::1]:47853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD87l-0002vr-Rq for importer@patchew.org; Tue, 23 May 2017 07:37:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD7pW-0003m4-N2 for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD7pV-0006Bb-Fg for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dD7pV-0006BB-69; Tue, 23 May 2017 07:18:21 -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 2CA5C15447; Tue, 23 May 2017 11:18:20 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-216.ams2.redhat.com [10.36.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC9FC77DCC; Tue, 23 May 2017 11:18:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2CA5C15447 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2CA5C15447 From: Laurent Vivier To: David Gibson Date: Tue, 23 May 2017 13:18:10 +0200 Message-Id: <20170523111812.13469-3-lvivier@redhat.com> In-Reply-To: <20170523111812.13469-1-lvivier@redhat.com> References: <20170523111812.13469-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.29]); Tue, 23 May 2017 11:18:20 +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 2/4] spapr: add option vector 6 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-ppc@nongnu.org, qemu-devel@nongnu.org, Michael Roth 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 allows to know when the OS is started and its type. Signed-off-by: Laurent Vivier --- hw/ppc/spapr.c | 36 ++++++++++++++++++++++++++++++++++++ hw/ppc/spapr_hcall.c | 5 ++++- hw/ppc/spapr_ovec.c | 8 ++++++++ include/hw/ppc/spapr.h | 2 ++ include/hw/ppc/spapr_ovec.h | 7 +++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0e8d8d1..eceb4cc 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1369,6 +1369,7 @@ static void ppc_spapr_reset(void) first_ppc_cpu->env.nip =3D SPAPR_ENTRY_POINT; =20 spapr->cas_reboot =3D false; + spapr->os_name =3D OV6_NONE; } =20 static void spapr_create_nvram(sPAPRMachineState *spapr) @@ -1524,10 +1525,41 @@ static const VMStateDescription vmstate_spapr_patb_= entry =3D { }, }; =20 +static bool spapr_os_name_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + return smc->need_os_name; +} + +static const VMStateDescription vmstate_spapr_os_name =3D { + .name =3D "spapr_os_name", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_os_name_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(os_name, sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + +static int spapr_pre_load(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + + /* if the os_name is not migrated from the source, + * we must allow hotplug, so set os_name to linux + */ + spapr->os_name =3D OV6_LINUX; + + return 0; +} + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, .minimum_version_id =3D 1, + .pre_load =3D spapr_pre_load, .post_load =3D spapr_post_load, .fields =3D (VMStateField[]) { /* used to be @next_irq */ @@ -1542,6 +1574,7 @@ static const VMStateDescription vmstate_spapr =3D { .subsections =3D (const VMStateDescription*[]) { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, + &vmstate_spapr_os_name, NULL } }; @@ -3216,6 +3249,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) * in which LMBs are represented and hot-added */ mc->numa_mem_align_shift =3D 28; + smc->need_os_name =3D true; } =20 static const TypeInfo spapr_machine_info =3D { @@ -3293,9 +3327,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->need_os_name =3D false; } =20 DEFINE_SPAPR_MACHINE(2_9, "2.9", false); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 0d608d6..5dbe3c7 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1058,7 +1058,8 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu, uint32_t max_compat =3D cpu->max_compat; uint32_t best_compat =3D 0; int i; - sPAPROptionVector *ov1_guest, *ov5_guest, *ov5_cas_old, *ov5_updates; + sPAPROptionVector *ov1_guest, *ov5_guest, *ov5_cas_old, *ov5_updates, + *ov6_guest; bool guest_radix; =20 /* @@ -1112,6 +1113,7 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu, =20 ov1_guest =3D spapr_ovec_parse_vector(ov_table, 1); ov5_guest =3D spapr_ovec_parse_vector(ov_table, 5); + ov6_guest =3D spapr_ovec_parse_vector(ov_table, 6); if (spapr_ovec_test(ov5_guest, OV5_MMU_BOTH)) { error_report("guest requested hash and radix MMU, which is invalid= ."); exit(EXIT_FAILURE); @@ -1154,6 +1156,7 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu, } spapr->cas_legacy_guest_workaround =3D !spapr_ovec_test(ov1_guest, OV1_PPC_3_00); + spapr->os_name =3D spapr_ovec_byte(ov6_guest, OV6_OS_NAME); if (!spapr->cas_reboot) { spapr->cas_reboot =3D (spapr_h_cas_compose_response(spapr, args[1], args[2], diff --git a/hw/ppc/spapr_ovec.c b/hw/ppc/spapr_ovec.c index 41df4c3..7adc9e6 100644 --- a/hw/ppc/spapr_ovec.c +++ b/hw/ppc/spapr_ovec.c @@ -160,6 +160,14 @@ static uint8_t guest_byte_from_bitmap(unsigned long *b= itmap, long bitmap_offset) return entry; } =20 +uint8_t spapr_ovec_byte(sPAPROptionVector *ov, long bitnr) +{ + g_assert(ov); + g_assert(bitnr < OV_MAXBITS); + + return guest_byte_from_bitmap(ov->bitmap, bitnr); +} + static target_ulong vector_addr(target_ulong table_addr, int vector) { uint16_t vector_count, vector_len; diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5802f88..041ce19 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -52,6 +52,7 @@ struct sPAPRMachineClass { /*< public >*/ bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ + bool need_os_name; const char *tcg_default_cpu; /* which (TCG) CPU to simulate by default= */ void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 @@ -90,6 +91,7 @@ struct sPAPRMachineState { sPAPROptionVector *ov5_cas; /* negotiated (via CAS) option vectors= */ bool cas_reboot; bool cas_legacy_guest_workaround; + uint8_t os_name; =20 Notifier epow_notifier; QTAILQ_HEAD(, sPAPREventLogEntry) pending_events; diff --git a/include/hw/ppc/spapr_ovec.h b/include/hw/ppc/spapr_ovec.h index f088833..c728bb3 100644 --- a/include/hw/ppc/spapr_ovec.h +++ b/include/hw/ppc/spapr_ovec.h @@ -56,6 +56,12 @@ typedef struct sPAPROptionVector sPAPROptionVector; #define OV5_MMU_RADIX_300 OV_BIT(24, 1) /* 1=3DRadix only, 0=3DHash = only */ #define OV5_MMU_RADIX_GTSE OV_BIT(26, 1) /* Radix GTSE */ =20 +/* option vector 6 */ +#define OV6_OS_NAME OV_BIT(3, 0) +#define OV6_NONE 0x00 +#define OV6_AIX 0x01 +#define OV6_LINUX 0x02 + /* interfaces */ sPAPROptionVector *spapr_ovec_new(void); sPAPROptionVector *spapr_ovec_clone(sPAPROptionVector *ov_orig); @@ -69,6 +75,7 @@ void spapr_ovec_cleanup(sPAPROptionVector *ov); void spapr_ovec_set(sPAPROptionVector *ov, long bitnr); void spapr_ovec_clear(sPAPROptionVector *ov, long bitnr); bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr); +uint8_t spapr_ovec_byte(sPAPROptionVector *ov, long bitnr); sPAPROptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int ve= ctor); int spapr_ovec_populate_dt(void *fdt, int fdt_offset, sPAPROptionVector *ov, const char *name); --=20 2.9.4 From nobody Sun Apr 28 00:02:05 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 1495539569633993.928727307462; Tue, 23 May 2017 04:39:29 -0700 (PDT) Received: from localhost ([::1]:47863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD89w-0004z0-CF for importer@patchew.org; Tue, 23 May 2017 07:39:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD7pY-0003nL-2I for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD7pX-0006Cr-8B for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60962) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dD7pX-0006CE-2C; Tue, 23 May 2017 07:18:23 -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 120373B73F; Tue, 23 May 2017 11:18:22 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-216.ams2.redhat.com [10.36.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C31377DCC; Tue, 23 May 2017 11:18:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 120373B73F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 120373B73F From: Laurent Vivier To: David Gibson Date: Tue, 23 May 2017 13:18:11 +0200 Message-Id: <20170523111812.13469-4-lvivier@redhat.com> In-Reply-To: <20170523111812.13469-1-lvivier@redhat.com> References: <20170523111812.13469-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.30]); Tue, 23 May 2017 11:18:22 +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 3/4] 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-ppc@nongnu.org, qemu-devel@nongnu.org, Michael Roth 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 use option vector 6 to know if the OS is started Signed-off-by: Laurent Vivier --- hw/ppc/spapr.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index eceb4cc..2e9320d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2625,6 +2625,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); @@ -2645,6 +2646,13 @@ static void spapr_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, goto out; } =20 + if (dev->hotplugged) { + if (!ms->os_name) { + error_setg(&local_err, "Memory hotplug not supported without O= S"); + goto out; + } + } + out: error_propagate(errp, local_err); } @@ -2874,6 +2882,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); @@ -2884,9 +2893,16 @@ static void spapr_core_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, int node_id; 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 (!ms->os_name) { + error_setg(&local_err, "CPU hotplug not supported without OS"); + goto out; + } } =20 if (strcmp(base_core_type, type)) { --=20 2.9.4 From nobody Sun Apr 28 00:02:05 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 1495539417745824.2859427948035; Tue, 23 May 2017 04:36:57 -0700 (PDT) Received: from localhost ([::1]:47852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD87U-0002h6-BU for importer@patchew.org; Tue, 23 May 2017 07:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD7pa-0003pv-DG for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD7pZ-0006Ei-Dj for qemu-devel@nongnu.org; Tue, 23 May 2017 07:18:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dD7pZ-0006E1-4V; Tue, 23 May 2017 07:18:25 -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 24EF73B74C; Tue, 23 May 2017 11:18:24 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-116-216.ams2.redhat.com [10.36.116.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6282F77DCC; Tue, 23 May 2017 11:18:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 24EF73B74C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lvivier@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 24EF73B74C From: Laurent Vivier To: David Gibson Date: Tue, 23 May 2017 13:18:12 +0200 Message-Id: <20170523111812.13469-5-lvivier@redhat.com> In-Reply-To: <20170523111812.13469-1-lvivier@redhat.com> References: <20170523111812.13469-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.30]); Tue, 23 May 2017 11:18:24 +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 4/4] 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-ppc@nongnu.org, qemu-devel@nongnu.org, Michael Roth 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. 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 --- 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 9fa5545..2bda00f 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -135,17 +135,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 (drc->type !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { @@ -447,11 +436,9 @@ static void detach(sPAPRDRConnector *drc, DeviceState = *d, } =20 if (drc->awaiting_allocation) { - if (!drc->awaiting_allocation_skippable) { - drc->awaiting_release =3D true; - trace_spapr_drc_awaiting_allocation(get_index(drc)); - return; - } + drc->awaiting_release =3D true; + trace_spapr_drc_awaiting_allocation(get_index(drc)); + return; } =20 drc->indicator_state =3D SPAPR_DR_INDICATOR_STATE_INACTIVE; @@ -461,7 +448,6 @@ static void detach(sPAPRDRConnector *drc, DeviceState *= d, } =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 5524247..fa531d5 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -154,7 +154,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