From nobody Sat May 4 18:40:00 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.zohomail.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 1505124956336191.7952495954546; Mon, 11 Sep 2017 03:15:56 -0700 (PDT) Received: from localhost ([::1]:56512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drLkx-00012d-K5 for importer@patchew.org; Mon, 11 Sep 2017 06:15:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drLjP-0008On-99 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 06:14:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drLjM-0002h9-4b for qemu-devel@nongnu.org; Mon, 11 Sep 2017 06:14:19 -0400 Received: from 13.mo1.mail-out.ovh.net ([178.33.253.128]:55240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drLjL-0002gF-V0 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 06:14:16 -0400 Received: from player169.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 818B093404 for ; Mon, 11 Sep 2017 12:14:14 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player169.ha.ovh.net (Postfix) with ESMTPA id 4817D580079; Mon, 11 Sep 2017 12:14:12 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 11 Sep 2017 12:14:12 +0200 Message-ID: <150512485206.8642.14117914178635650186.stgit@bahia.lan> In-Reply-To: <150512483616.8642.15831240906912354238.stgit@bahia.lan> References: <150512483616.8642.15831240906912354238.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 7058829469574994259 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgedtgddvjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.253.128 Subject: [Qemu-devel] [PATCH 1/2] spapr_pci: convert sprintf() to g_strdup_printf() 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 Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 In order to follow a QEMU common practice. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 75cd9392233e..7d84b9766ed2 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1609,34 +1609,37 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) =20 sphb->dtbusname =3D g_strdup_printf("pci@%" PRIx64, sphb->buid); =20 - namebuf =3D alloca(strlen(sphb->dtbusname) + 32); - /* Initialize memory regions */ - sprintf(namebuf, "%s.mmio", sphb->dtbusname); + namebuf =3D g_strdup_printf("%s.mmio", sphb->dtbusname); memory_region_init(&sphb->memspace, OBJECT(sphb), namebuf, UINT64_MAX); + g_free(namebuf); =20 - sprintf(namebuf, "%s.mmio32-alias", sphb->dtbusname); + namebuf =3D g_strdup_printf("%s.mmio32-alias", sphb->dtbusname); memory_region_init_alias(&sphb->mem32window, OBJECT(sphb), namebuf, &sphb->memspace, SPAPR_PCI_MEM_WIN_BUS_OFFSET, sphb->mem_win_s= ize); + g_free(namebuf); memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr, &sphb->mem32window); =20 - sprintf(namebuf, "%s.mmio64-alias", sphb->dtbusname); + namebuf =3D g_strdup_printf("%s.mmio64-alias", sphb->dtbusname); memory_region_init_alias(&sphb->mem64window, OBJECT(sphb), namebuf, &sphb->memspace, sphb->mem64_win_pciaddr, sphb->mem64_win_size= ); + g_free(namebuf); memory_region_add_subregion(get_system_memory(), sphb->mem64_win_addr, &sphb->mem64window); =20 /* Initialize IO regions */ - sprintf(namebuf, "%s.io", sphb->dtbusname); + namebuf =3D g_strdup_printf("%s.io", sphb->dtbusname); memory_region_init(&sphb->iospace, OBJECT(sphb), namebuf, SPAPR_PCI_IO_WIN_SIZE); + g_free(namebuf); =20 - sprintf(namebuf, "%s.io-alias", sphb->dtbusname); + namebuf =3D g_strdup_printf("%s.io-alias", sphb->dtbusname); memory_region_init_alias(&sphb->iowindow, OBJECT(sphb), namebuf, &sphb->iospace, 0, SPAPR_PCI_IO_WIN_SIZE); + g_free(namebuf); memory_region_add_subregion(get_system_memory(), sphb->io_win_addr, &sphb->iowindow); =20 @@ -1654,10 +1657,10 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) * Later the guest might want to create another DMA window * which will become another memory subregion. */ - sprintf(namebuf, "%s.iommu-root", sphb->dtbusname); - + namebuf =3D g_strdup_printf("%s.iommu-root", sphb->dtbusname); memory_region_init(&sphb->iommu_root, OBJECT(sphb), namebuf, UINT64_MAX); + g_free(namebuf); address_space_init(&sphb->iommu_as, &sphb->iommu_root, sphb->dtbusname); =20 From nobody Sat May 4 18:40:00 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.zohomail.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 1505124967248568.5871802286802; Mon, 11 Sep 2017 03:16:07 -0700 (PDT) Received: from localhost ([::1]:56513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drLl8-0001Ae-4A for importer@patchew.org; Mon, 11 Sep 2017 06:16:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drLjW-0008V0-Mf for qemu-devel@nongnu.org; Mon, 11 Sep 2017 06:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drLjT-0002lY-Hu for qemu-devel@nongnu.org; Mon, 11 Sep 2017 06:14:26 -0400 Received: from 12.mo1.mail-out.ovh.net ([87.98.162.229]:44411) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drLjT-0002kZ-BP for qemu-devel@nongnu.org; Mon, 11 Sep 2017 06:14:23 -0400 Received: from player169.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id F1EB99308D for ; Mon, 11 Sep 2017 12:14:21 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player169.ha.ovh.net (Postfix) with ESMTPA id B9548580079; Mon, 11 Sep 2017 12:14:19 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 11 Sep 2017 12:14:19 +0200 Message-ID: <150512485953.8642.2754721062817370406.stgit@bahia.lan> In-Reply-To: <150512483616.8642.15831240906912354238.stgit@bahia.lan> References: <150512483616.8642.15831240906912354238.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 7060799793917761875 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgedtgddvjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.162.229 Subject: [Qemu-devel] [PATCH 2/2] spapr_pci: don't create 64-bit MMIO window if we don't need to 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 Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 When running a pseries-2.2 or older machine type, we get the following lines in info mtree: address-space: memory ... ffffffffffffffff-ffffffffffffffff (prio 0, i/o): alias pci@800000020000000.mmio64-alias @pci@800000020000000.mmio ffffffffffffffff-ffffffffffffffff address-space: cpu-memory ... ffffffffffffffff-ffffffffffffffff (prio 0, i/o): alias pci@800000020000000.mmio64-alias @pci@800000020000000.mmio ffffffffffffffff-ffffffffffffffff The same thing occurs when running a pseries-2.7 with -global spapr-pci-host-bridge.mem_win_size=3D2147483648 This happens because we always create a 64-bit MMIO window, even if we didn't explicitely requested it (ie, mem64_win_size =3D=3D 0) and the 32-bit window is below 2GiB. It doesn't seem to have an impact on the guest though because spapr_populate_pci_dt() doesn't advertise the bogus windows when mem64_win_size =3D=3D 0. Since these memory regions don't induce any state, we can safely choose to not create them when their address is equal to -1, without breaking migration from existing setups. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7d84b9766ed2..cf54160526fa 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1622,13 +1622,19 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr, &sphb->mem32window); =20 - namebuf =3D g_strdup_printf("%s.mmio64-alias", sphb->dtbusname); - memory_region_init_alias(&sphb->mem64window, OBJECT(sphb), - namebuf, &sphb->memspace, - sphb->mem64_win_pciaddr, sphb->mem64_win_size= ); - g_free(namebuf); - memory_region_add_subregion(get_system_memory(), sphb->mem64_win_addr, - &sphb->mem64window); + if (sphb->mem64_win_pciaddr !=3D (hwaddr)-1) { + namebuf =3D g_strdup_printf("%s.mmio64-alias", sphb->dtbusname); + memory_region_init_alias(&sphb->mem64window, OBJECT(sphb), + namebuf, &sphb->memspace, + sphb->mem64_win_pciaddr, sphb->mem64_win_= size); + g_free(namebuf); + + if (sphb->mem64_win_addr !=3D (hwaddr)-1) { + memory_region_add_subregion(get_system_memory(), + sphb->mem64_win_addr, + &sphb->mem64window); + } + } =20 /* Initialize IO regions */ namebuf =3D g_strdup_printf("%s.io", sphb->dtbusname);