From nobody Fri Apr 26 12:57:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555334939; cv=none; d=zoho.com; s=zohoarc; b=MX4FTbML54GZaLas5AMTOKKJYqZx4mwwPBUF8Pp/gd65UQdwLhPY9dLKj3UryZL5Ri0kAScIjT2bwVYCY0sJHhZ7AjdBBoy0c4rh749gum9bKv05aWJMrqdh3fMsQSy6g1OL17wgrTjqUx5Wmwzcutpho2kOWscfyZQhTRmYJyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555334939; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Zsf095iuXuwOCRoZeoI/Oj302vUtB13A6SjUd2znC5M=; b=C8zf2HquJd8wJx4J8cwfkyD8sfeHhrTilsGApEDwFqIy8Da5piBpiuZbM3AnxPNYrhuAMg07h024pj1rm57uH5ygIEdeaHMuMBn95TliE8XhD6p2QVdaooo1FcMxf04XwMlvsB+ru1dAlTQIhpuuafqNST8XYzMAZvr3vMRgfg8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555334939112705.9219790110458; Mon, 15 Apr 2019 06:28:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:50250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1fL-0005oT-4Q for importer@patchew.org; Mon, 15 Apr 2019 09:28:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1dm-0004eJ-Pw for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hG1dk-00052s-T0 for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46850) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hG1dj-00051g-09; Mon, 15 Apr 2019 09:27:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB7DE3092645; Mon, 15 Apr 2019 13:27:12 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC53E1001E6D; Mon, 15 Apr 2019 13:27:06 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2019 15:27:18 +0200 Message-Id: <1555334842-195718-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1555334842-195718-1-git-send-email-imammedo@redhat.com> References: <1555334842-195718-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 15 Apr 2019 13:27:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 1/5] sparc64: use memory_region_allocate_system_memory() only for '-m' specified RAM 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: qemu-ppc@nongnu.org, David Hildenbrand , Helge Deller , Cornelia Huck , Mark Cave-Ayland , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Richard Henderson , Artyom Tarasenko , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" memory_region_allocate_system_memory() was designed to be called for allocating inital RAM. Using it mutiple times within one board is not supported and could fail if -mem-path with non hugepage path is used. Keep using memory_region_allocate_system_memory() only for initial RAM and use memory_region_init_ram() for the rest fixed size regions. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/sparc64/niagara.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c index f8a856f..39a4522 100644 --- a/hw/sparc64/niagara.c +++ b/hw/sparc64/niagara.c @@ -37,6 +37,7 @@ #include "sysemu/block-backend.h" #include "qemu/error-report.h" #include "sysemu/qtest.h" +#include "qapi/error.h" =20 =20 typedef struct NiagaraBoardState { @@ -108,8 +109,8 @@ static void niagara_init(MachineState *machine) /* init CPUs */ sparc64_cpu_devinit(machine->cpu_type, NIAGARA_PROM_BASE); /* set up devices */ - memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram", - NIAGARA_HV_RAM_SIZE); + memory_region_init_ram(&s->hv_ram, NULL, "sun4v-hv.ram", + NIAGARA_HV_RAM_SIZE, &error_fatal); memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram); =20 memory_region_allocate_system_memory(&s->partition_ram, NULL, @@ -118,17 +119,17 @@ static void niagara_init(MachineState *machine) memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE, &s->partition_ram); =20 - memory_region_allocate_system_memory(&s->nvram, NULL, - "sun4v.nvram", NIAGARA_NVRAM_SIZE= ); + memory_region_init_ram(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_S= IZE, + &error_fatal); memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram); - memory_region_allocate_system_memory(&s->md_rom, NULL, - "sun4v-md.rom", NIAGARA_MD_ROM_SI= ZE); + memory_region_init_ram(&s->md_rom, NULL, "sun4v-md.rom", + NIAGARA_MD_ROM_SIZE, &error_fatal); memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom); - memory_region_allocate_system_memory(&s->hv_rom, NULL, - "sun4v-hv.rom", NIAGARA_HV_ROM_SI= ZE); + memory_region_init_ram(&s->hv_rom, NULL, "sun4v-hv.rom", + NIAGARA_HV_ROM_SIZE, &error_fatal); memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom); - memory_region_allocate_system_memory(&s->prom, NULL, - "sun4v.prom", PROM_SIZE_MAX); + memory_region_init_ram(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX, + &error_fatal); memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom); =20 add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE); @@ -145,8 +146,8 @@ static void niagara_init(MachineState *machine) BlockBackend *blk =3D blk_by_legacy_dinfo(dinfo); int size =3D blk_getlength(blk); if (size > 0) { - memory_region_allocate_system_memory(&s->vdisk_ram, NULL, - "sun4v_vdisk.ram", size); + memory_region_init_ram(&s->vdisk_ram, NULL, "sun4v_vdisk.ram",= size, + &error_fatal); memory_region_add_subregion(get_system_memory(), NIAGARA_VDISK_BASE, &s->vdisk_ram); dinfo->is_default =3D 1; --=20 2.7.4 From nobody Fri Apr 26 12:57:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555335016; cv=none; d=zoho.com; s=zohoarc; b=ReeDF5yY+YHGk7g03E7FZmzlyIuZnbVNUIxCGBssPWbjALLh9eLADOSXb4wWmIm9e0fNthh5eD+tkMQpuAfH8RnFMVMRdRqud8X1CWFKrIcu5SEmEtKC6dkkTPQaD+423mXwSvZfYYljOgO+b8UV0PeP+2ZCMAR2fRw7EgibIcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555335016; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KjaHK9L0uRzmrIly+Sn01NlbyIKSL305qY9QRhE3v3c=; b=VwJ7/OKlp5XEH9RSDofQ8+R3A3r1qhtq7+EE9YGfG+2HHsyIlEhgWmeBf2jFNRVhzJHwyqZ+86LhGuzhXZTU/S3wJpUdM9JGdxfBA/aXVgfHUcS886ZUP6fUpQF2rUsTcyfMr7cFcD9O6Iv3ijMz0NG7Gr/h9N/rL7lgtG5Ii5g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555335016387665.7839367520619; Mon, 15 Apr 2019 06:30:16 -0700 (PDT) Received: from localhost ([127.0.0.1]:50264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1gY-0006dP-Cc for importer@patchew.org; Mon, 15 Apr 2019 09:30:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1dp-0004fg-1h for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hG1dm-00053k-Ti for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36822) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hG1dm-00052d-34; Mon, 15 Apr 2019 09:27:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBAD73098557; Mon, 15 Apr 2019 13:27:15 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C39D1001E6D; Mon, 15 Apr 2019 13:27:13 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2019 15:27:19 +0200 Message-Id: <1555334842-195718-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1555334842-195718-1-git-send-email-imammedo@redhat.com> References: <1555334842-195718-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 15 Apr 2019 13:27:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 2/5] ppc: rs6000_mc: drop usage of memory_region_allocate_system_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: qemu-ppc@nongnu.org, David Hildenbrand , Helge Deller , Cornelia Huck , Mark Cave-Ayland , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Richard Henderson , Artyom Tarasenko , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" rs6000mc_realize() violates memory_region_allocate_system_memory() contract by calling it multiple times which could break -mem-path. Replace it with plain memory_region_init_ram() instead. Signed-off-by: Igor Mammedov Acked-by: David Gibson --- hw/ppc/rs6000_mc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c index 45cb95e..ea174f1 100644 --- a/hw/ppc/rs6000_mc.c +++ b/hw/ppc/rs6000_mc.c @@ -142,6 +142,7 @@ static void rs6000mc_realize(DeviceState *dev, Error **= errp) RS6000MCState *s =3D RS6000MC_DEVICE(dev); int socket =3D 0; unsigned int ram_size =3D s->ram_size / MiB; + Error *local_err =3D NULL; =20 while (socket < 6) { if (ram_size >=3D 64) { @@ -163,19 +164,21 @@ static void rs6000mc_realize(DeviceState *dev, Error = **errp) if (s->simm_size[socket]) { char name[] =3D "simm.?"; name[5] =3D socket + '0'; - memory_region_allocate_system_memory(&s->simm[socket], OBJECT(= dev), - name, - s->simm_size[socket] * Mi= B); + memory_region_init_ram(&s->simm[socket], OBJECT(dev), name, + s->simm_size[socket] * MiB, &local_err); + if (local_err) { + goto out; + } memory_region_add_subregion_overlap(get_system_memory(), 0, &s->simm[socket], socket); } } if (ram_size) { /* unable to push all requested RAM in SIMMs */ - error_setg(errp, "RAM size incompatible with this board. " + error_setg(&local_err, "RAM size incompatible with this board. " "Try again with something else, like %" PRId64 " MB", s->ram_size / MiB - ram_size); - return; + goto out; } =20 if (s->autoconfigure) { @@ -191,6 +194,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **= errp) =20 isa_register_portio_list(ISA_DEVICE(dev), &s->portio, 0x0, rs6000mc_port_list, s, "rs6000mc"); +out: + error_propagate(errp, local_err); } =20 static const VMStateDescription vmstate_rs6000mc =3D { --=20 2.7.4 From nobody Fri Apr 26 12:57:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555335200; cv=none; d=zoho.com; s=zohoarc; b=Ivm6kLUg5CQCxBuPAtALY04cE/B8sCWXfbbcJM/FPehWlZxfJGNW4vHJBLgYfT8ep2R3tkOg+LVLO88f7aYnRUAEi7j5wZKID6IKntfUd2mGi7iQHRqoJGqBsqDrLrvMW41NCbGngAKHKohiaJTbGHMQ4qRw2Ci4vwyjEiZgzbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555335200; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GHPK1va89tTNj2+YddsnXnkRrkSAsX6DfQ7v8AyCrKc=; b=EzSRnVtQYq2CWM7mvVfBDQ4xx4105T76KKro67skPqCAmbYOXCY4AHZYOIBkNOs+q7XbqPPr35xFrBED0nWXXhuoMvEpAcYn/ugvlgSoApFIJzyvYBwwy0zSwo+xxb+m/3TRBxU+qDlOIVmQxa3r2BvWTQeo94R3Y4fkDwO9rj8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555335200254936.0984144428063; Mon, 15 Apr 2019 06:33:20 -0700 (PDT) Received: from localhost ([127.0.0.1]:50334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1jX-0000J9-9P for importer@patchew.org; Mon, 15 Apr 2019 09:33:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1ds-0004jH-Tx for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hG1dq-00055L-TY for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hG1do-00053y-Vm; Mon, 15 Apr 2019 09:27:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDF723007C25; Mon, 15 Apr 2019 13:27:18 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E5831001E84; Mon, 15 Apr 2019 13:27:16 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2019 15:27:20 +0200 Message-Id: <1555334842-195718-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1555334842-195718-1-git-send-email-imammedo@redhat.com> References: <1555334842-195718-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 15 Apr 2019 13:27:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 3/5] hppa: drop usage of memory_region_allocate_system_memory() for ROM 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: qemu-ppc@nongnu.org, David Hildenbrand , Helge Deller , Cornelia Huck , Mark Cave-Ayland , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Richard Henderson , Artyom Tarasenko , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" machine_hppa_init() violates memory_region_allocate_system_memory() contract by calling it multiple times which could break with -mem-path. Replace the second usage (for 'rom') with memory_region_init_ram() instead. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/hppa/machine.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index d1b1d3c..b413913 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -158,9 +158,8 @@ static void machine_hppa_init(MachineState *machine) g_free(firmware_filename); =20 rom_region =3D g_new(MemoryRegion, 1); - memory_region_allocate_system_memory(rom_region, OBJECT(machine), - "firmware", - (FIRMWARE_END - FIRMWARE_START)); + memory_region_init_ram(rom_region, NULL, "firmware", + (FIRMWARE_END - FIRMWARE_START), &error_fatal); memory_region_add_subregion(addr_space, FIRMWARE_START, rom_region); =20 /* Load kernel */ --=20 2.7.4 From nobody Fri Apr 26 12:57:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555335047; cv=none; d=zoho.com; s=zohoarc; b=YQJA3NfEkJTknLSAuZqR1P1EtjhKaMHgJ0FMiy3xgIM+R0o+r3c8w7mUgJ2kOJVV2WRenTN3rojQOUqI3TIHhDqgFWyK5hIZbupb3LNFecb7lwTWMp4dbF2qx+6qbkJm8N0flnj4GKTXSPozo8aiyMmtIXPC6p5HBz+p/77kWf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555335047; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=k8P6OVmadiTEbJUb7sj0sNAffreKBqv11nEiE/NMIsM=; b=eK4hprdTFivJ4EjQmyFRoN3AaMYeEGnjTEnDbxzxSHM2v+F0jGuPfpLJjDkNB70wgoWSoZchHm18YLjle4+TNxqQK1vAAHchQp6/MsT8iW8n80Dc189BDe0LUTapRT4wRKgvvzaVpSNw8lRijalF/Y67UtE7+PU4QNIZKr5zfuQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555335047078356.897338328862; Mon, 15 Apr 2019 06:30:47 -0700 (PDT) Received: from localhost ([127.0.0.1]:50304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1h3-00075V-3W for importer@patchew.org; Mon, 15 Apr 2019 09:30:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1ds-0004jE-Tp for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hG1dr-00055i-4r for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58837) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hG1dq-000557-TN; Mon, 15 Apr 2019 09:27:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A70FFC04D30D; Mon, 15 Apr 2019 13:27:21 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 105C61001DDD; Mon, 15 Apr 2019 13:27:18 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2019 15:27:21 +0200 Message-Id: <1555334842-195718-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1555334842-195718-1-git-send-email-imammedo@redhat.com> References: <1555334842-195718-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 15 Apr 2019 13:27:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 4/5] memory: make MemoryRegion alias migratable 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: qemu-ppc@nongnu.org, David Hildenbrand , Helge Deller , Cornelia Huck , Mark Cave-Ayland , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Richard Henderson , Artyom Tarasenko , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" use qemu_ram_alloc_from_ptr() to create aliased RAMBlock to the part of original memory region. Signed-off-by: Igor Mammedov --- exec.c | 7 ++++--- memory.c | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/exec.c b/exec.c index 6ab62f4..0fc10d1 100644 --- a/exec.c +++ b/exec.c @@ -2255,7 +2255,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp, bool shared) new_block->used_length, DIRTY_CLIENTS_ALL); =20 - if (new_block->host) { + if (new_block->host && !new_block->mr->alias) { qemu_ram_setup_dump(new_block->host, new_block->max_length); qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUG= EPAGE); /* MADV_DONTFORK is also needed by KVM in absence of synchronous M= MU */ @@ -2613,7 +2613,8 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool ro= und_offset, =20 rcu_read_lock(); block =3D atomic_rcu_read(&ram_list.mru_block); - if (block && block->host && host - block->host < block->max_length) { + if (block && !block->mr->alias && block->host && + host - block->host < block->max_length) { goto found; } =20 @@ -2622,7 +2623,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool ro= und_offset, if (block->host =3D=3D NULL) { continue; } - if (host - block->host < block->max_length) { + if (!block->mr->alias && host - block->host < block->max_length) { goto found; } } diff --git a/memory.c b/memory.c index 9fbca52..687a147 100644 --- a/memory.c +++ b/memory.c @@ -1672,6 +1672,11 @@ void memory_region_init_alias(MemoryRegion *mr, memory_region_init(mr, owner, name, size); mr->alias =3D orig; mr->alias_offset =3D offset; + if (orig->ram_block && size) { + mr->ram_block =3D qemu_ram_alloc_from_ptr(size, + orig->ram_block->host + of= fset, + mr, &error_fatal); + } } =20 void memory_region_init_rom_nomigrate(MemoryRegion *mr, --=20 2.7.4 From nobody Fri Apr 26 12:57:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555335275; cv=none; d=zoho.com; s=zohoarc; b=g/vAHvWc+jYhDm1c4aCbAv7DvSWgalUixYoCHBjNKnTzC1SVMahL9Owxq2OD5Pc2WiekrKGMpnlBu25kVwEE8HKxAJhGJRL5Q6pLgvLBTnIBIqfkEmBWCqEag4Ud0i/mlzu8t/43tQbLDYWsoM9iP83TpChmEsNT0HJlYhuXRo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555335275; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/L5U5KTNjvu0YRoUIusMU6H75uCo8xeojFHe9RgfvoQ=; b=BAr6EZ2Ahx+CGm4mzmyMDRO70egccUzaty0xvICMmW9S7SR6p/1z6Kfx5Za3ILnY/UVu8/8mImGTvVMQI1mTL4DNcIYHysn4JNgMwdAsFlfp1wlGhtDv7NE/1FEx06I5x9JTPU/tpaqMG+o2S+54q3qI3XrntmrbjIVdn4kRfJ8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555335275115985.0026730476357; Mon, 15 Apr 2019 06:34:35 -0700 (PDT) Received: from localhost ([127.0.0.1]:50342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1kj-0000xV-6z for importer@patchew.org; Mon, 15 Apr 2019 09:34:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hG1e0-0004rt-B8 for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hG1dy-00059s-Ew for qemu-devel@nongnu.org; Mon, 15 Apr 2019 09:27:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hG1dw-00058E-FX; Mon, 15 Apr 2019 09:27:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA5BE307EA98; Mon, 15 Apr 2019 13:27:26 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7D0A1001DDD; Mon, 15 Apr 2019 13:27:21 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2019 15:27:22 +0200 Message-Id: <1555334842-195718-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1555334842-195718-1-git-send-email-imammedo@redhat.com> References: <1555334842-195718-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 15 Apr 2019 13:27:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 5/5] s390: do not call memory_region_allocate_system_memory() multiple times 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: qemu-ppc@nongnu.org, David Hildenbrand , Helge Deller , Cornelia Huck , Mark Cave-Ayland , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Richard Henderson , Artyom Tarasenko , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" s390 was trying to solve limited memslot size issue by abusing memory_region_allocate_system_memory(), which breaks API contract where the function might be called only once. s390 should have used memory aliases to fragment inital memory into smaller chunks to satisfy KVM's memslot limitation. But its a bit late now, since allocated pieces are transfered in migration stream separately, so it's not possible to just replace broken layout with correct one. Previous patch made MemoryRegion alases migratable and this patch switches to use them to split big initial RAM chunk into smaller pieces up to KVM_SLOT_MAX_BYTES each and registers aliases for migration. Signed-off-by: Igor Mammedov --- A don't have access to a suitable system to test it, so I've simulated it with smaller chunks on x84 host. Ping-pong migration between old and new QEMU worked fine. KVM part should be fine as memslots using mapped MemoryRegions (in this case it would be aliases) as far as I know but is someone could test it on big enough host it would be nice. --- hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index d11069b..12ca3a9 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -161,20 +161,30 @@ static void virtio_ccw_register_hcalls(void) static void s390_memory_init(ram_addr_t mem_size) { MemoryRegion *sysmem =3D get_system_memory(); + MemoryRegion *ram =3D g_new(MemoryRegion, 1); ram_addr_t chunk, offset =3D 0; unsigned int number =3D 0; gchar *name; =20 /* allocate RAM for core */ + memory_region_allocate_system_memory(ram, NULL, "s390.whole.ram", mem_= size); + /* + * memory_region_allocate_system_memory() registers allocated RAM for + * migration, however for compat reasons the RAM should be passed over + * as RAMBlocks of the size upto KVM_SLOT_MAX_BYTES. So unregister just + * allocated RAM so it won't be migrated directly. Aliases will take + * of segmenting RAM into legacy chunks. + */ + vmstate_unregister_ram(ram, NULL); name =3D g_strdup_printf("s390.ram"); while (mem_size) { - MemoryRegion *ram =3D g_new(MemoryRegion, 1); - uint64_t size =3D mem_size; + MemoryRegion *alias =3D g_new(MemoryRegion, 1); =20 /* KVM does not allow memslots >=3D 8 TB */ - chunk =3D MIN(size, KVM_SLOT_MAX_BYTES); - memory_region_allocate_system_memory(ram, NULL, name, chunk); - memory_region_add_subregion(sysmem, offset, ram); + chunk =3D MIN(mem_size, KVM_SLOT_MAX_BYTES); + memory_region_init_alias(alias, NULL, name, ram, offset, chunk); + vmstate_register_ram_global(alias); + memory_region_add_subregion(sysmem, offset, alias); mem_size -=3D chunk; offset +=3D chunk; g_free(name); --=20 2.7.4