From patchwork Mon Sep 11 10:14:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 812296 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xrP1j3Jwbz9s7f for ; Mon, 11 Sep 2017 20:15:05 +1000 (AEST) Received: from localhost ([::1]:56504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drLk7-0008WS-Ft for incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 06:15:03 -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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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, Error **errp) sphb->dtbusname = g_strdup_printf("pci@%" PRIx64, sphb->buid); - namebuf = alloca(strlen(sphb->dtbusname) + 32); - /* Initialize memory regions */ - sprintf(namebuf, "%s.mmio", sphb->dtbusname); + namebuf = g_strdup_printf("%s.mmio", sphb->dtbusname); memory_region_init(&sphb->memspace, OBJECT(sphb), namebuf, UINT64_MAX); + g_free(namebuf); - sprintf(namebuf, "%s.mmio32-alias", sphb->dtbusname); + namebuf = 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_size); + g_free(namebuf); memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr, &sphb->mem32window); - sprintf(namebuf, "%s.mmio64-alias", sphb->dtbusname); + namebuf = 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); /* Initialize IO regions */ - sprintf(namebuf, "%s.io", sphb->dtbusname); + namebuf = g_strdup_printf("%s.io", sphb->dtbusname); memory_region_init(&sphb->iospace, OBJECT(sphb), namebuf, SPAPR_PCI_IO_WIN_SIZE); + g_free(namebuf); - sprintf(namebuf, "%s.io-alias", sphb->dtbusname); + namebuf = 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); @@ -1654,10 +1657,10 @@ static void spapr_phb_realize(DeviceState *dev, Error **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 = 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); From patchwork Mon Sep 11 10:14:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 812297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xrP1w25zRz9s7f for ; Mon, 11 Sep 2017 20:15:16 +1000 (AEST) Received: from localhost ([::1]:56505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drLkI-0000ES-AY for incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 06:15:14 -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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=2147483648 This happens because we always create a 64-bit MMIO window, even if we didn't explicitely requested it (ie, mem64_win_size == 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 == 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, Error **errp) memory_region_add_subregion(get_system_memory(), sphb->mem_win_addr, &sphb->mem32window); - namebuf = 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 != (hwaddr)-1) { + namebuf = 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 != (hwaddr)-1) { + memory_region_add_subregion(get_system_memory(), + sphb->mem64_win_addr, + &sphb->mem64window); + } + } /* Initialize IO regions */ namebuf = g_strdup_printf("%s.io", sphb->dtbusname);