From patchwork Thu Jun 20 14:44:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 252981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ACBC62C02A9 for ; Fri, 21 Jun 2013 00:52:58 +1000 (EST) Received: from localhost ([::1]:45760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpgEK-0001D4-NI for incoming@patchwork.ozlabs.org; Thu, 20 Jun 2013 10:52:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upg7V-0007PK-OK for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:46:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upg7Q-0007Iu-H5 for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:45:53 -0400 Received: from mail-ea0-x229.google.com ([2a00:1450:4013:c01::229]:36356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upg7Q-0007IX-4x for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:45:48 -0400 Received: by mail-ea0-f169.google.com with SMTP id h15so4103011eak.28 for ; Thu, 20 Jun 2013 07:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=RyF243zt8CvATOujT05k7uJebDEAEnh2NjQ9Mk6gw5M=; b=rx7Do1XUOIDk2NfXtadVKUbuI0rpunIFOeWxZOQrRccUiYcQyYoenzCEiFcN45KwOJ l5OnVMF3D5lImNg7WlqjBV+xkTBNllM/E54OyOW+qjILvi1r0EYNN6tKJ6xZ7ORbRZXR YPKEsczGFfwBRLsYQugasQOgx882EEm6Sz/xL1LF+oIwReOtj+KpzaJQz2gxeXCnho98 GVwMqwQXWHFh/moz6nkIE5K7oiFY7vDaPwyqA7v3oFoLV/9FQSTbcLSZ7nZoW7UZe3+f Tyzig2S+s4dxzERUqSF9rcWy8gMP0J8Wmwa2y6qiq4MWWe/QL0DWsU27MKhLQg/DGUfI fvIw== X-Received: by 10.14.175.5 with SMTP id y5mr8125564eel.21.1371739547396; Thu, 20 Jun 2013 07:45:47 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id y10sm973958eev.3.2013.06.20.07.45.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 20 Jun 2013 07:45:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 20 Jun 2013 16:44:50 +0200 Message-Id: <1371739493-10187-23-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371739493-10187-1-git-send-email-pbonzini@redhat.com> References: <1371739493-10187-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::229 Cc: Alexey Kardashevskiy Subject: [Qemu-devel] [PATCH 22/25] memory: give name to every AddressSpace X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alexey Kardashevskiy The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpace structs created by PCI and VIO devices. Those devices do not normally have names and therefore not present in "info mtree" output. The patch fixes this. Reviewed-by: Peter Maydell Signed-off-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini --- exec.c | 6 ++---- hw/pci/pci.c | 3 ++- hw/ppc/spapr_pci.c | 4 +++- hw/ppc/spapr_vio.c | 2 +- include/exec/memory.h | 6 ++++-- memory.c | 8 +++----- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/exec.c b/exec.c index a18f833..0b0118b 100644 --- a/exec.c +++ b/exec.c @@ -1827,13 +1827,11 @@ static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, "system", INT64_MAX); - address_space_init(&address_space_memory, system_memory); - address_space_memory.name = "memory"; + address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "io", 65536); - address_space_init(&address_space_io, system_io); - address_space_io.name = "I/O"; + address_space_init(&address_space_io, system_io, "I/O"); memory_listener_register(&core_memory_listener, &address_space_memory); memory_listener_register(&io_memory_listener, &address_space_io); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 104fe71..61b681a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -814,7 +814,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); - address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region); + address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, + name); pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 459398c..04e8362 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -650,7 +650,9 @@ static int spapr_phb_init(SysBusDevice *s) fprintf(stderr, "Unable to create TCE table for %s\n", sphb->dtbusname); return -1; } - address_space_init(&sphb->iommu_as, spapr_tce_get_iommu(sphb->tcet)); + address_space_init(&sphb->iommu_as, spapr_tce_get_iommu(sphb->tcet), + sphb->dtbusname); + pci_setup_iommu(bus, spapr_pci_dma_iommu, sphb); QLIST_INSERT_HEAD(&spapr->phbs, sphb, list); diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 459c9f2..3c5a655 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -454,7 +454,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev) if (pc->rtce_window_size) { uint32_t liobn = SPAPR_VIO_BASE_LIOBN | dev->reg; dev->tcet = spapr_tce_new_table(liobn, pc->rtce_window_size); - address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet)); + address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet), qdev->id); } return pc->init(dev); diff --git a/include/exec/memory.h b/include/exec/memory.h index 75fa2b6..3598c4f 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -192,7 +192,7 @@ struct MemoryRegionPortio { */ struct AddressSpace { /* All fields are private. */ - const char *name; + char *name; MemoryRegion *root; struct FlatView *current_map; int ioeventfd_nb; @@ -892,8 +892,10 @@ void mtree_info(fprintf_function mon_printf, void *f); * * @as: an uninitialized #AddressSpace * @root: a #MemoryRegion that routes addesses for the address space + * @name: an address space name. The name is only used for debugging + * output. */ -void address_space_init(AddressSpace *as, MemoryRegion *root); +void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name); /** diff --git a/memory.c b/memory.c index 2a94d7d..8e99b8a 100644 --- a/memory.c +++ b/memory.c @@ -1657,7 +1657,7 @@ void memory_listener_unregister(MemoryListener *listener) QTAILQ_REMOVE(&memory_listeners, listener, link); } -void address_space_init(AddressSpace *as, MemoryRegion *root) +void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) { memory_region_transaction_begin(); as->root = root; @@ -1666,7 +1666,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root) as->ioeventfd_nb = 0; as->ioeventfds = NULL; QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); - as->name = NULL; + as->name = g_strdup(name ? name : "anonymous"); address_space_init_dispatch(as); memory_region_update_pending |= root->enabled; memory_region_transaction_commit(); @@ -1681,6 +1681,7 @@ void address_space_destroy(AddressSpace *as) QTAILQ_REMOVE(&address_spaces, as, address_spaces_link); address_space_destroy_dispatch(as); flatview_destroy(as->current_map); + g_free(as->name); g_free(as->current_map); g_free(as->ioeventfds); } @@ -1807,9 +1808,6 @@ void mtree_info(fprintf_function mon_printf, void *f) QTAILQ_INIT(&ml_head); QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { - if (!as->name) { - continue; - } mon_printf(f, "%s\n", as->name); mtree_print_mr(mon_printf, f, as->root, 0, 0, &ml_head); }