From patchwork Thu Aug 19 14:20:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1518699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=e1N72JPy; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gr6QY6mYmz9sX1 for ; Fri, 20 Aug 2021 00:21:41 +1000 (AEST) Received: from localhost ([::1]:50194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGivL-0002ZD-Nf for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2021 10:21:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuY-0002Wq-OU for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:20:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuX-0006K9-7W for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:20:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y5OsBr5b+5HKE5I63CA5hALHkGW01POgsrNsZU+ahb0=; b=e1N72JPyAKWPod20xEnwPHf/9i62Bdlzm7lVmNS+S9flwmXqh0Lgwpk08VPSBy1OK7yUju NOUB/ZpPIy1uSCk6UP0qLdnTwSvmzyTsyAHhIdCGPdScRk6FMDroNiS0zz2prkkzWwhxNM +8vQ+GdXdKhFRwBnYfbI5POSAnCg674= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-33ttK-Z1PhOGwVoWGDp0eA-1; Thu, 19 Aug 2021 10:20:47 -0400 X-MC-Unique: 33ttK-Z1PhOGwVoWGDp0eA-1 Received: by mail-wm1-f70.google.com with SMTP id e12-20020a05600c218cb02902e6bbacdcd1so1595719wme.4 for ; Thu, 19 Aug 2021 07:20:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y5OsBr5b+5HKE5I63CA5hALHkGW01POgsrNsZU+ahb0=; b=GzStCRYOZ5yJrKDcqS7NrvCrLFdj1hYAErbo3a4HXtqfoz9/h6g4oYKazHxCDeuP6k BJhQgFVkS7LaqWmkAefFhnuqzgMWfQ9f3yrTMwHZvK519SJktHYHTppizAttpYrvQCap +rsVkC+UDI1UlZ9VutI7ba1bU1khZgPcEysphvdhVnyrRTbdF7JzXx59lLhA3NpDlBW2 zSDuPqgFImOqOmWDNURsJaf7c+1m87kzbrGXWUZJL8Fqo4z8vfRHpTlTtgqib0w+1tbq ei4phYIS1vhslvDy4I096NN6O6FtX+hOOERy0E/vmV+8TvE3jh5jaZjDeF8HLoyD8BbG EIug== X-Gm-Message-State: AOAM530i/8yQvdguOEXSBCufcCHhk2TUurU/4TpB85M8QwgQCetAg6YR TFkbkId6SQQO0eJ5BGW00rPof6lOsl/uAJhR1dXX0PPBgW+Ww6QLQwxigcd6L/ONgbqxad14wmS +8JS820EqKmuhBDeNw1KygiD7ApU7mFeyf+39jttuykxPhb91YaX8u912XDlN7FmI X-Received: by 2002:adf:979d:: with SMTP id s29mr4193904wrb.264.1629382845868; Thu, 19 Aug 2021 07:20:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOQQg7SUZDT8Ua7TTsIjbDHXvO2BvwFOOZBnS5xjMwLwvaT9myfC5ahgs+4geIDDElGxRx9w== X-Received: by 2002:adf:979d:: with SMTP id s29mr4193876wrb.264.1629382845714; Thu, 19 Aug 2021 07:20:45 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id j17sm2999870wrt.69.2021.08.19.07.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:20:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/6] memory: Do not increase refcount on global system_memory region Date: Thu, 19 Aug 2021 16:20:34 +0200 Message-Id: <20210819142039.2825366-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" system_memory is statically allocated in memory_map_init() (softmmu/physmem.c) and is never destroyed. No need to increment its refcount. Signed-off-by: Philippe Mathieu-Daudé --- softmmu/memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index bfedaf9c4df..185f978c925 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -24,7 +24,7 @@ #include "qemu/qemu-print.h" #include "qom/object.h" #include "trace.h" - +#include "exec/address-spaces.h" #include "exec/memory-internal.h" #include "exec/ram_addr.h" #include "sysemu/kvm.h" @@ -2923,7 +2923,9 @@ void address_space_remove_listeners(AddressSpace *as) void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) { - memory_region_ref(root); + if (root != get_system_memory()) { + memory_region_ref(root); + } as->root = root; as->current_map = NULL; as->ioeventfd_nb = 0; From patchwork Thu Aug 19 14:20:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1518702 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=J8XElWAN; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gr6T43M2qz9sX1 for ; Fri, 20 Aug 2021 00:23:52 +1000 (AEST) Received: from localhost ([::1]:58258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGixS-00084C-4F for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2021 10:23:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiud-0002hL-Em for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:20:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiub-0006O7-R1 for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:20:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S5J953m8jthIx8YKw7RXWxnSJEtO9PzEi6CmU+gZmWk=; b=J8XElWANuvAW+3XgD0jb9mwQBQiEr/mkEXxtN2kTk0lOvxNn1m+DUV826UbKaM8hdx3Lek 0ZYACnpwd3GLvPKwQGrNFfePBYJCh9V/8a9vG9EXNBiVGOhQAlm4X+5Iq/5TQ9C1zAgBtC BwbkbRx4ieYfxso3zXk3fW18PcBNLgI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-602-ithVkMyrMIS75XwCLD5HCA-1; Thu, 19 Aug 2021 10:20:52 -0400 X-MC-Unique: ithVkMyrMIS75XwCLD5HCA-1 Received: by mail-wm1-f71.google.com with SMTP id c2-20020a7bc8420000b0290238db573ab7so3549321wml.5 for ; Thu, 19 Aug 2021 07:20:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S5J953m8jthIx8YKw7RXWxnSJEtO9PzEi6CmU+gZmWk=; b=XON+rdA0SWUG3bN9ZXNVENu1Xk3fyIlqS3zDyI9QUUWryIrbVyzWGb2InBZwcaj0mB VXkcbEZCIkH60EVMZqSdsj/GH2h4Z2feSJJjl/IHwrRpJedEWL6GmCKgz8ZWiTV/n6Ra Ddyg5bTbkvEu68HvaOOFE24VSqZm9y3R9Eot3edAML18eLgcYrHB7XyO8fzoeHGvAoxb S2lUKgXC97u3rn9i+VweZlQyFu6kLBLFUabXMQiaLYOKyOmRjE4twDkTnZO6X4BRWDX4 d6sMRBDo2TBGXKkoYtG0deN+EfnCMged1VJol91PmNAON8xOZJFT8M8D/2glue8n6uk5 I00A== X-Gm-Message-State: AOAM5332c2fWnO9+QELM7kEShhsW6PbWJSWf3rjZ3fkAXBp3+VZzHB/e DZ1+rnUyThjHiBxU/jYIdnB/n7NND0mnD9omBjcWPX18aDf8aJ0oFsykOQ+usCmYlmSKzeQXFPQ XrRrupVw2FOIK9vCJ+/1BBG8BHmxVMXYGqt7tYn9APTw0yUWNIaZik06tsvfinfhF X-Received: by 2002:a7b:cc16:: with SMTP id f22mr13857478wmh.99.1629382850788; Thu, 19 Aug 2021 07:20:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwljsaK8xTKC3ZxT9A69p0K+bI18Pkfe97AyeppN9b9VIrWOghxSBpZCtS3dKIT74BP9VJCnA== X-Received: by 2002:a7b:cc16:: with SMTP id f22mr13857427wmh.99.1629382850326; Thu, 19 Aug 2021 07:20:50 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id n10sm2984641wrw.76.2021.08.19.07.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:20:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/6] memory: Introduce address_space_create() Date: Thu, 19 Aug 2021 16:20:35 +0200 Message-Id: <20210819142039.2825366-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Introduce address_space_create(). In is similar to address_space_init() but returns a pointer to a heap allocated AddressSpace. Signed-off-by: Philippe Mathieu-Daudé --- include/exec/memory.h | 14 ++++++++++++++ softmmu/memory.c | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index c3d417d317f..b353a48c25f 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2418,6 +2418,20 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, */ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name); +/** + * address_space_create: Create and initializes an address space + * + * @root: a #MemoryRegion that routes addresses for the address space + * @name: an address space name. The name is only used for debugging + * output. + * + * Returns pointer to initialized #AddressSpace. + * + * The caller is responsible for releasing the pointer returned + * with address_space_destroy() after use. + */ +AddressSpace *address_space_create(MemoryRegion *root, const char *name); + /** * address_space_destroy: destroy an address space * diff --git a/softmmu/memory.c b/softmmu/memory.c index 185f978c925..16a2b518d8d 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2937,6 +2937,16 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) address_space_update_ioeventfds(as); } +AddressSpace *address_space_create(MemoryRegion *root, const char *name) +{ + AddressSpace *as; + + as = g_new(AddressSpace, 1); + address_space_init(as, root, name); + + return as; +} + static void do_address_space_destroy(AddressSpace *as) { assert(QTAILQ_EMPTY(&as->listeners)); From patchwork Thu Aug 19 14:20:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1518700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TSx5xljV; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gr6R41fZMz9sX1 for ; Fri, 20 Aug 2021 00:22:08 +1000 (AEST) Received: from localhost ([::1]:50848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGivl-000313-OJ for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2021 10:22:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuj-0002wZ-2J for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiug-0006SO-Ea for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=shIeo+L4trmRqnGxLVVjByJ3DfeCv4gt22CJ/6RIBwg=; b=TSx5xljV2NPcuvO8lJEYWgJdmHEUvjHN23XGTMlDeTex5oxsudZ//1TLTaIbvdCZgrQ7d0 5IYH6z1/pn2C7TlaJ0izYAPLBIlF1EP/TxsiCGq4nB68jqKNakm0u8MlN5Z5oH/VcRhdsF f4iHWjfXi9cuwc3K2FvEPOPyVo3qLrs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-444-d13u_1d4Nsmh4O2qwOaGhw-1; Thu, 19 Aug 2021 10:20:56 -0400 X-MC-Unique: d13u_1d4Nsmh4O2qwOaGhw-1 Received: by mail-wm1-f69.google.com with SMTP id j33-20020a05600c1c21b02902e6828f7a20so1593770wms.7 for ; Thu, 19 Aug 2021 07:20:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=shIeo+L4trmRqnGxLVVjByJ3DfeCv4gt22CJ/6RIBwg=; b=TaTIL8LCyVsc7VqJfesrp17uuJOv/RmdR0rOwUVRsBISxIqR/TNNTwvLxfYOXkCAkZ u3T7YfclIvrr2AwJWzwCbv/smjQb2D7KyAME5pK+cGE/xlLBUUjXvvBmm+9Yz/4UnMUS KjcDuM+mhby+VqyiSpZ+k37DIjwODZUt6ZbvmN65zPL0+zRMPlJbtd3r6QLE2ZSB2cUM U5rrw3H1VB56ZJ9F5u5gFZSpaWZByRNGgkAJJelrGK8YBQrbQ1HeoPmhGkO+8nK9L3kD zU7hl7YaMa0Lxz25w2tTIGne7v+s2YIyKcsPM3ZM+igOvP2niyYm1O7d7x0XYfBPqyUU 0Qsw== X-Gm-Message-State: AOAM533CN47/clz2distnL/93Huv5s4goqmGOaDVR5amvMYgVIyGxhII l4otSNmgzgXJJ267uugLNF0wBj86eCXzvhLVnTv47o7rLvxly6B3B48Qt34OKVD4wSv2i1Q+yDb on4PEj7rt4gvgL2STHYap590H38AGrUPxsUtGsvFgwwSJOlP+H1eu5uZuBG2J0+DM X-Received: by 2002:adf:fcc5:: with SMTP id f5mr4361110wrs.114.1629382855531; Thu, 19 Aug 2021 07:20:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7zYOEIkNEOHV3YtZGTXYk83thhYe0ux9YT5xw3f3FLHXQD1bguzTgmuzMe0mBmOaptHmC3A== X-Received: by 2002:adf:fcc5:: with SMTP id f5mr4361077wrs.114.1629382855386; Thu, 19 Aug 2021 07:20:55 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id g6sm2847345wmq.14.2021.08.19.07.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:20:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/6] memory: Have cpu_address_space_init() use address_space_create() Date: Thu, 19 Aug 2021 16:20:36 +0200 Message-Id: <20210819142039.2825366-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Replace g_new0() + address_space_init() by address_space_create(). Signed-off-by: Philippe Mathieu-Daudé --- softmmu/physmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 3c1912a1a07..cd8b670a731 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -727,12 +727,12 @@ void cpu_address_space_init(CPUState *cpu, int asidx, const char *prefix, MemoryRegion *mr) { CPUAddressSpace *newas; - AddressSpace *as = g_new0(AddressSpace, 1); + AddressSpace *as; char *as_name; assert(mr); as_name = g_strdup_printf("%s-%d", prefix, cpu->cpu_index); - address_space_init(as, mr, as_name); + as = address_space_create(mr, as_name); g_free(as_name); /* Target code should have set num_ases before calling us */ From patchwork Thu Aug 19 14:20:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1518701 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JQFkEu0C; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gr6RS731cz9t0Y for ; Fri, 20 Aug 2021 00:22:28 +1000 (AEST) Received: from localhost ([::1]:52064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGiw6-0003rj-KM for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2021 10:22:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuq-0003L3-Gu for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuo-0006ZF-TJ for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zZLP80M+KMpFzOA/bjjaS/ry2kFipBSjMsh/PACigbc=; b=JQFkEu0CqBGwyZ2nY7HJbwkaEyYcclqIwD8VuQOM42Cbecua0yTvsuBiL7INhXNw9AbGfk e+gCYu/uCQwhr9TNdBxpVEXyeyBWK2j5dfKxbJrNnBi7tptt1o3yGfzTuqCqSjmSQ2Rz/v nW2hZg91I/wFjehwH0IEXxtE3AqUUZc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-S8QMZQsIPzmvHUh1X0BD3A-1; Thu, 19 Aug 2021 10:21:02 -0400 X-MC-Unique: S8QMZQsIPzmvHUh1X0BD3A-1 Received: by mail-wr1-f72.google.com with SMTP id l1-20020adff481000000b00156e670a09dso1767315wro.1 for ; Thu, 19 Aug 2021 07:21:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zZLP80M+KMpFzOA/bjjaS/ry2kFipBSjMsh/PACigbc=; b=aanvx06+uNZWgyAcitcwwk54cru19suC0rpVhbUxkXXfe4C8/23ZXPWAgxtv70NFV2 qZ6CJtffLqjNtKMrDZAT6gnAuFnXg4AEVqnXMPt+DR7txSaDieW1xtHUG6IeHsSixVfg 8WAIg8zMuj9EXFQZQRq0qu4FUK6MQzxmI7wWssFvzu7FnVSRqPBqF8teRst4kdpwfWqm FgJs/FISIapuvpSNX4vjdS+MXQ89BMngjeSy0cjtyV4LqmMnA2QGqD+6Q6Cw82FjCX6r 0LIhUi3aFu8Bcw3gLCmj0kjtt6xj9pF50dsvcLo630Z1OZMaLpqCcMg5sMofRqeznIH3 yryQ== X-Gm-Message-State: AOAM530cjwYID2McRBXCf3LIZFksqOmKfUdH7iOBiHCPSyjwYQUVm7mo 1W2Ga0v7SC5jCDOzjBeKjJiLwNzUSGJCO4w+2gmPbMr+LQAw5EVCUpooo88wIoDmzSaHPM5HxD3 Uli8i1YfrIfexkjmLliO32ckjvsQ/Czv8/ocW81H22Ao1FAOvYN/IC/nEBDvigtPI X-Received: by 2002:adf:fb8d:: with SMTP id a13mr4371240wrr.164.1629382860196; Thu, 19 Aug 2021 07:21:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRDdE5l3tFMlrawDe6jBMujrunyjEgjm9hDLsAevR0HAqyGZiyFsUm6Y+xoVG1YZVto2dhwQ== X-Received: by 2002:adf:fb8d:: with SMTP id a13mr4371209wrr.164.1629382860023; Thu, 19 Aug 2021 07:21:00 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id u23sm7816790wmc.24.2021.08.19.07.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:20:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/6] hw/dma: Replace alloc() + address_space_init() by address_space_create() Date: Thu, 19 Aug 2021 16:20:37 +0200 Message-Id: <20210819142039.2825366-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Replace g_malloc0() + address_space_init() by address_space_create(). Release the resource in DeviceUnrealize(). Signed-off-by: Philippe Mathieu-Daudé --- hw/dma/xlnx-zdma.c | 15 +++++++++------ hw/dma/xlnx_csu_dma.c | 9 ++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c index fa38a556341..9f6b3fa47c6 100644 --- a/hw/dma/xlnx-zdma.c +++ b/hw/dma/xlnx-zdma.c @@ -777,15 +777,17 @@ static void zdma_realize(DeviceState *dev, Error **errp) }; } - if (s->dma_mr) { - s->dma_as = g_malloc0(sizeof(AddressSpace)); - address_space_init(s->dma_as, s->dma_mr, NULL); - } else { - s->dma_as = &address_space_memory; - } + s->dma_as = address_space_create(s->dma_mr ?: get_system_memory(), NULL); s->attr = MEMTXATTRS_UNSPECIFIED; } +static void zdma_unrealize(DeviceState *dev) +{ + XlnxZDMA *s = XLNX_ZDMA(dev); + + address_space_destroy(s->dma_as); +} + static void zdma_init(Object *obj) { XlnxZDMA *s = XLNX_ZDMA(obj); @@ -827,6 +829,7 @@ static void zdma_class_init(ObjectClass *klass, void *data) dc->reset = zdma_reset; dc->realize = zdma_realize; + dc->unrealize = zdma_unrealize; device_class_set_props(dc, zdma_props); dc->vmsd = &vmstate_zdma; } diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c index 0c1c19cab5a..730c0f999ce 100644 --- a/hw/dma/xlnx_csu_dma.c +++ b/hw/dma/xlnx_csu_dma.c @@ -648,13 +648,7 @@ static void xlnx_csu_dma_realize(DeviceState *dev, Error **errp) s->src_timer = ptimer_init(xlnx_csu_dma_src_timeout_hit, s, PTIMER_POLICY_DEFAULT); - if (s->dma_mr) { - s->dma_as = g_malloc0(sizeof(AddressSpace)); - address_space_init(s->dma_as, s->dma_mr, NULL); - } else { - s->dma_as = &address_space_memory; - } - + s->dma_as = address_space_create(s->dma_mr ?: get_system_memory(), NULL); s->attr = MEMTXATTRS_UNSPECIFIED; s->r_size_last_word = 0; @@ -665,6 +659,7 @@ static void xlnx_csu_dma_unrealize(DeviceState *dev) XlnxCSUDMA *s = XLNX_CSU_DMA(dev); ptimer_free(s->src_timer); + address_space_destroy(s->dma_as); } static const VMStateDescription vmstate_xlnx_csu_dma = { From patchwork Thu Aug 19 14:20:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1518703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ra/pc2k+; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gr6Tb1lvgz9sX1 for ; Fri, 20 Aug 2021 00:24:19 +1000 (AEST) Received: from localhost ([::1]:60606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGixs-0001DM-V3 for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2021 10:24:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuu-0003Wt-M9 for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiut-0006cM-08 for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WwxcFzkUhr+SPEjC7KEdcFzv7DLvVmTT/gW/kFoiXv4=; b=Ra/pc2k+gd4qPejwVeCr/SWfi3JtOefj9dHA12Yjf9KJK0gjf99M++t0JGEnCIJssDuxW7 +PBOA+lkCXryK9QSLxssWYIc+pahYk5JwCvA7rMoB4Hd236qsjiEOZjJXhUVMhYgWTkfvt ifz6S9W+wi+ydZP+zyqVUpJHri9U2nQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-448-ZKI1NEybNbad2g7hTygUGw-1; Thu, 19 Aug 2021 10:21:07 -0400 X-MC-Unique: ZKI1NEybNbad2g7hTygUGw-1 Received: by mail-wm1-f71.google.com with SMTP id b3-20020a1c80030000b02902e6a7296cb3so1374545wmd.5 for ; Thu, 19 Aug 2021 07:21:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WwxcFzkUhr+SPEjC7KEdcFzv7DLvVmTT/gW/kFoiXv4=; b=ZXK9G+iAlSo/cMdPP/D2UoIm1mWGd6Du2vGdbnW5z0twMicJXtxgRi1oxoxl6k2SKO fyY/5FS2jlMRv1gVEGZb1Gjj+qk6Gzc0mWplgSv96/WZdS0h+SYXS8XePUkJLK9Gdylq 95mGhxRsTxkBbS9jrb41Ezia+Ysxxfkiul86UvIOsn7pzx2mnNIMO5d/J/Dqo2XN37Jd HGmjaP/u9jh4vidpALro+/mzQ3rVFdykxYuVYvCz0VBxuJROAu2G44kcD6mohq+XcH/4 UcG6G9C5/+LZjKKOw+Pfb+TEm6YdUDU2X2hqfPi+o5TCGn0g0Sj1AemXMujPbpnclMBS Mf/w== X-Gm-Message-State: AOAM531eHGmdkmKQJY7QPC4NdZss+PKRImjlf+1LHShsJhw2UnF36BNa uoNnleWMQkresJO0WWFmZQuSfiDVFj9rpXwRcwxTHRnP6vroYyzV3UzBBFlFoyRM9XxSw9RP+uE 5xvGalS/3xqE+cJbddZ1clfsPQiNyc+mnn7VR212AL7kWniOAbYeq8HkH3deovnks X-Received: by 2002:a1c:2090:: with SMTP id g138mr14014786wmg.98.1629382865480; Thu, 19 Aug 2021 07:21:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjl4adP85e/ASWOoCVCYhPNY8xtrTPIrXPck7e9y+Cm5aHE4fKA3pr9YrjCEboKpsVNMjJnw== X-Received: by 2002:a1c:2090:: with SMTP id g138mr14014758wmg.98.1629382865260; Thu, 19 Aug 2021 07:21:05 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id j16sm3054713wrr.78.2021.08.19.07.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:21:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/6] hw/usb: Replace alloc() + address_space_init() by address_space_create() Date: Thu, 19 Aug 2021 16:20:38 +0200 Message-Id: <20210819142039.2825366-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Replace g_malloc0() + address_space_init() by address_space_create(). Release the resource in DeviceUnrealize(). Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-xhci-sysbus.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c index a14e4381960..04ac485e8b3 100644 --- a/hw/usb/hcd-xhci-sysbus.c +++ b/hw/usb/hcd-xhci-sysbus.c @@ -43,16 +43,19 @@ static void xhci_sysbus_realize(DeviceState *dev, Error **errp) s->irq = g_new0(qemu_irq, s->xhci.numintrs); qdev_init_gpio_out_named(dev, s->irq, SYSBUS_DEVICE_GPIO_IRQ, s->xhci.numintrs); - if (s->xhci.dma_mr) { - s->xhci.as = g_malloc0(sizeof(AddressSpace)); - address_space_init(s->xhci.as, s->xhci.dma_mr, NULL); - } else { - s->xhci.as = &address_space_memory; - } + s->xhci.as = address_space_create(s->xhci.dma_mr ?: get_system_memory(), + NULL); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->xhci.mem); } +static void xhci_sysbus_unrealize(DeviceState *dev) +{ + XHCISysbusState *s = XHCI_SYSBUS(dev); + + address_space_destroy(s->xhci.as); +} + static void xhci_sysbus_instance_init(Object *obj) { XHCISysbusState *s = XHCI_SYSBUS(obj); @@ -103,6 +106,7 @@ static void xhci_sysbus_class_init(ObjectClass *klass, void *data) dc->reset = xhci_sysbus_reset; dc->realize = xhci_sysbus_realize; + dc->unrealize = xhci_sysbus_unrealize; dc->vmsd = &vmstate_xhci_sysbus; device_class_set_props(dc, xhci_sysbus_props); } From patchwork Thu Aug 19 14:20:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1518704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=daPx9HJE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gr6VL6r61z9sX1 for ; Fri, 20 Aug 2021 00:24:58 +1000 (AEST) Received: from localhost ([::1]:34546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGiyW-0002dK-Ob for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2021 10:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuy-0003f2-Hh for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGiuv-0006gV-IP for qemu-devel@nongnu.org; Thu, 19 Aug 2021 10:21:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QEyWPjQ7Gf9BUPz8WL5PzOlCAdvMwlwVzwTeHocd/5s=; b=daPx9HJETfmKooFyIoZ0r0+exmFUutScKBn9dGBkrARVyM4Ekvj5HJJll7zZLIbjVJfMkE qfFoBlqx4DM1s18jImk0Qw22Er76YTS1BWZrOQURL9/tR5cgm/iZcw0uUFhCIHBxsNXrfT S7rBueqsKlQ60C+ggHz4aeODiMd5yrs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-fuL0hYlvMBKY6cZhMLpYyw-1; Thu, 19 Aug 2021 10:21:12 -0400 X-MC-Unique: fuL0hYlvMBKY6cZhMLpYyw-1 Received: by mail-wm1-f71.google.com with SMTP id j33-20020a05600c1c21b02902e6828f7a20so1593975wms.7 for ; Thu, 19 Aug 2021 07:21:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QEyWPjQ7Gf9BUPz8WL5PzOlCAdvMwlwVzwTeHocd/5s=; b=ClXVsHRalQ0Bj3cZWF2mOSenR3pMHVUSBzMYYWV1xMfzZ/avdF0Csz9gcpOCS0mpZL 0SqMu+/xMrllOWCCqYylR7OfqSgq6U+Nch6b81D1UrnG92AUc/wVGi4i8cmedTzT7vqB ODxe9QV1Uml47hHkXLUZ+1Kg4X1JlopO+V3jBR4DfPw838cM9+XmmgLBLTd/69Zl4RP5 vOLeBYkDD7WNwE0c8aB7gwFG+zHrdBtQnVEON1IShgLHB+Cp2GsO9wGfzyYYxnyIjxzr nofpo6QGEPQZfH/u2979PJRO1/CL4KX+0wEl3k3zN1h7v2P0jleYajsd0Ssu0e1feOmE 1TKw== X-Gm-Message-State: AOAM5308Xipap9KUVnCVl2MXcpUbW+u+IOdnRZwy+ACGeMpP1SBRXmK8 zp/G050ugcot+JJjb6Oxx1xdX0Me428SU/4iAZkU+WcoKZvTgtaacdUNop9dmbMpNY5g4DcnYZ8 GU3jFD7PtM3Y+jlSBqUg8Sipp2wAu2rhU8FizG5R19CiwRj0kXEINpuBY5zyipzEW X-Received: by 2002:a7b:c756:: with SMTP id w22mr13968329wmk.169.1629382870409; Thu, 19 Aug 2021 07:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU2eFmgEMwmeuxPkpBabQdTNmtrIGJQ5ir7VEREfQX+1H+HLk1sQXOB7OkSAlvY+9nPvSZzg== X-Received: by 2002:a7b:c756:: with SMTP id w22mr13968302wmk.169.1629382870176; Thu, 19 Aug 2021 07:21:10 -0700 (PDT) Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id j17sm3000947wrt.69.2021.08.19.07.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 07:21:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 6/6] memory: Have address_space_create() re-use global &address_space_memory Date: Thu, 19 Aug 2021 16:20:39 +0200 Message-Id: <20210819142039.2825366-7-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819142039.2825366-1-philmd@redhat.com> References: <20210819142039.2825366-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Mark Cave-Ayland , Alistair Francis , Jianxian Wen , Peter Xu , qemu-arm@nongnu.org, Gerd Hoffmann , Paolo Bonzini , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We already have a global AddressSpace created along with the global get_system_memory(): address_space_memory. Return it directly instead of creating the same AS with a different name. This drastically reduce 'info mtree' on some boards (diff -c100): (echo info mtree; echo q) | ./qemu-system-aarch64 -S -monitor stdio -M raspi3b QEMU 6.0.93 monitor - type 'help' for more information (qemu) info mtree address-space: memory 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-000000003fffffff (prio 0, ram): ram 000000003f000000-000000003fffffff (prio 1, i/o): bcm2835-peripherals 000000003f003000-000000003f00301f (prio 0, i/o): bcm2835-sys-timer 000000003f004000-000000003f004fff (prio -1000, i/o): bcm2835-txp 000000003f006000-000000003f006fff (prio 0, i/o): mphi 000000003f007000-000000003f007fff (prio 0, i/o): bcm2835-dma 000000003f00b200-000000003f00b3ff (prio 0, i/o): bcm2835-ic 000000003f00b400-000000003f00b43f (prio -1000, i/o): bcm2835-sp804 000000003f00b800-000000003f00bbff (prio 0, i/o): bcm2835-mbox 000000003f100000-000000003f1001ff (prio 0, i/o): bcm2835-powermgt 000000003f101000-000000003f102fff (prio 0, i/o): bcm2835-cprman 000000003f104000-000000003f10400f (prio 0, i/o): bcm2835-rng 000000003f200000-000000003f200fff (prio 0, i/o): bcm2835_gpio 000000003f201000-000000003f201fff (prio 0, i/o): pl011 000000003f202000-000000003f202fff (prio 0, i/o): bcm2835-sdhost 000000003f203000-000000003f2030ff (prio -1000, i/o): bcm2835-i2s 000000003f204000-000000003f20401f (prio -1000, i/o): bcm2835-spi0 000000003f205000-000000003f20501f (prio -1000, i/o): bcm2835-i2c0 000000003f20f000-000000003f20f07f (prio -1000, i/o): bcm2835-otp 000000003f212000-000000003f212007 (prio 0, i/o): bcm2835-thermal 000000003f214000-000000003f2140ff (prio -1000, i/o): bcm2835-spis 000000003f215000-000000003f2150ff (prio 0, i/o): bcm2835-aux 000000003f300000-000000003f3000ff (prio 0, i/o): sdhci 000000003f600000-000000003f6000ff (prio -1000, i/o): bcm2835-smi 000000003f804000-000000003f80401f (prio -1000, i/o): bcm2835-i2c1 000000003f805000-000000003f80501f (prio -1000, i/o): bcm2835-i2c2 000000003f900000-000000003f907fff (prio -1000, i/o): bcm2835-dbus 000000003f910000-000000003f917fff (prio -1000, i/o): bcm2835-ave0 000000003f980000-000000003f990fff (prio 0, i/o): dwc2 000000003f980000-000000003f980fff (prio 0, i/o): dwc2-io 000000003f981000-000000003f990fff (prio 0, i/o): dwc2-fifo 000000003fc00000-000000003fc00fff (prio -1000, i/o): bcm2835-v3d 000000003fe00000-000000003fe000ff (prio -1000, i/o): bcm2835-sdramc 000000003fe05000-000000003fe050ff (prio 0, i/o): bcm2835-dma-chan15 0000000040000000-00000000400000ff (prio 0, i/o): bcm2836-control address-space: I/O 0000000000000000-000000000000ffff (prio 0, i/o): io address-space: bcm2835-mbox-memory 0000000000000000-000000000000008f (prio 0, i/o): bcm2835-mbox 0000000000000010-000000000000001f (prio 0, i/o): bcm2835-fb 0000000000000080-000000000000008f (prio 0, i/o): bcm2835-property address-space: bcm2835-fb-memory 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff address-space: bcm2835-property-memory 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff address-space: bcm2835-dma-memory 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff address-space: dwc2 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff - address-space: cpu-secure-memory-0 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system - 0000000000000000-000000003fffffff (prio 0, ram): ram - 000000003f000000-000000003fffffff (prio 1, i/o): bcm2835-peripherals - 000000003f003000-000000003f00301f (prio 0, i/o): bcm2835-sys-timer - 000000003f004000-000000003f004fff (prio -1000, i/o): bcm2835-txp - 000000003f006000-000000003f006fff (prio 0, i/o): mphi - 000000003f007000-000000003f007fff (prio 0, i/o): bcm2835-dma - 000000003f00b200-000000003f00b3ff (prio 0, i/o): bcm2835-ic - 000000003f00b400-000000003f00b43f (prio -1000, i/o): bcm2835-sp804 - 000000003f00b800-000000003f00bbff (prio 0, i/o): bcm2835-mbox - 000000003f100000-000000003f1001ff (prio 0, i/o): bcm2835-powermgt - 000000003f101000-000000003f102fff (prio 0, i/o): bcm2835-cprman - 000000003f104000-000000003f10400f (prio 0, i/o): bcm2835-rng - 000000003f200000-000000003f200fff (prio 0, i/o): bcm2835_gpio - 000000003f201000-000000003f201fff (prio 0, i/o): pl011 - 000000003f202000-000000003f202fff (prio 0, i/o): bcm2835-sdhost - 000000003f203000-000000003f2030ff (prio -1000, i/o): bcm2835-i2s - 000000003f204000-000000003f20401f (prio -1000, i/o): bcm2835-spi0 - 000000003f205000-000000003f20501f (prio -1000, i/o): bcm2835-i2c0 - 000000003f20f000-000000003f20f07f (prio -1000, i/o): bcm2835-otp - 000000003f212000-000000003f212007 (prio 0, i/o): bcm2835-thermal - 000000003f214000-000000003f2140ff (prio -1000, i/o): bcm2835-spis - 000000003f215000-000000003f2150ff (prio 0, i/o): bcm2835-aux - 000000003f300000-000000003f3000ff (prio 0, i/o): sdhci - 000000003f600000-000000003f6000ff (prio -1000, i/o): bcm2835-smi - 000000003f804000-000000003f80401f (prio -1000, i/o): bcm2835-i2c1 - 000000003f805000-000000003f80501f (prio -1000, i/o): bcm2835-i2c2 - 000000003f900000-000000003f907fff (prio -1000, i/o): bcm2835-dbus - 000000003f910000-000000003f917fff (prio -1000, i/o): bcm2835-ave0 - 000000003f980000-000000003f990fff (prio 0, i/o): dwc2 - 000000003f980000-000000003f980fff (prio 0, i/o): dwc2-io - 000000003f981000-000000003f990fff (prio 0, i/o): dwc2-fifo - 000000003fc00000-000000003fc00fff (prio -1000, i/o): bcm2835-v3d - 000000003fe00000-000000003fe000ff (prio -1000, i/o): bcm2835-sdramc - 000000003fe05000-000000003fe050ff (prio 0, i/o): bcm2835-dma-chan15 - 0000000040000000-00000000400000ff (prio 0, i/o): bcm2836-control - - address-space: cpu-memory-0 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-secure-memory-1 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-memory-1 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-secure-memory-2 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-memory-2 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-secure-memory-3 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - - address-space: cpu-memory-3 - 0000000000000000-ffffffffffffffff (prio 0, i/o): system [...] - memory-region: ram 0000000000000000-000000003fffffff (prio 0, ram): ram memory-region: bcm2835-peripherals 000000003f000000-000000003fffffff (prio 1, i/o): bcm2835-peripherals 000000003f003000-000000003f00301f (prio 0, i/o): bcm2835-sys-timer 000000003f004000-000000003f004fff (prio -1000, i/o): bcm2835-txp 000000003f006000-000000003f006fff (prio 0, i/o): mphi 000000003f007000-000000003f007fff (prio 0, i/o): bcm2835-dma 000000003f00b200-000000003f00b3ff (prio 0, i/o): bcm2835-ic 000000003f00b400-000000003f00b43f (prio -1000, i/o): bcm2835-sp804 000000003f00b800-000000003f00bbff (prio 0, i/o): bcm2835-mbox 000000003f100000-000000003f1001ff (prio 0, i/o): bcm2835-powermgt 000000003f101000-000000003f102fff (prio 0, i/o): bcm2835-cprman 000000003f104000-000000003f10400f (prio 0, i/o): bcm2835-rng 000000003f200000-000000003f200fff (prio 0, i/o): bcm2835_gpio 000000003f201000-000000003f201fff (prio 0, i/o): pl011 000000003f202000-000000003f202fff (prio 0, i/o): bcm2835-sdhost 000000003f203000-000000003f2030ff (prio -1000, i/o): bcm2835-i2s 000000003f204000-000000003f20401f (prio -1000, i/o): bcm2835-spi0 000000003f205000-000000003f20501f (prio -1000, i/o): bcm2835-i2c0 000000003f20f000-000000003f20f07f (prio -1000, i/o): bcm2835-otp 000000003f212000-000000003f212007 (prio 0, i/o): bcm2835-thermal 000000003f214000-000000003f2140ff (prio -1000, i/o): bcm2835-spis 000000003f215000-000000003f2150ff (prio 0, i/o): bcm2835-aux 000000003f300000-000000003f3000ff (prio 0, i/o): sdhci 000000003f600000-000000003f6000ff (prio -1000, i/o): bcm2835-smi 000000003f804000-000000003f80401f (prio -1000, i/o): bcm2835-i2c1 000000003f805000-000000003f80501f (prio -1000, i/o): bcm2835-i2c2 000000003f900000-000000003f907fff (prio -1000, i/o): bcm2835-dbus 000000003f910000-000000003f917fff (prio -1000, i/o): bcm2835-ave0 000000003f980000-000000003f990fff (prio 0, i/o): dwc2 000000003f980000-000000003f980fff (prio 0, i/o): dwc2-io 000000003f981000-000000003f990fff (prio 0, i/o): dwc2-fifo 000000003fc00000-000000003fc00fff (prio -1000, i/o): bcm2835-v3d 000000003fe00000-000000003fe000ff (prio -1000, i/o): bcm2835-sdramc 000000003fe05000-000000003fe050ff (prio 0, i/o): bcm2835-dma-chan15 (qemu) q Inspired-by: Jianxian Wen Signed-off-by: Philippe Mathieu-Daudé --- Note, we loose the specific description of the duplicated address spaces, but this doesn't seem very useful in this output, it is rather more confusing IMO. --- softmmu/memory.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/softmmu/memory.c b/softmmu/memory.c index 16a2b518d8d..e4506b5a0d5 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2941,6 +2941,10 @@ AddressSpace *address_space_create(MemoryRegion *root, const char *name) { AddressSpace *as; + if (root == get_system_memory()) { + return &address_space_memory; + } + as = g_new(AddressSpace, 1); address_space_init(as, root, name); @@ -2961,6 +2965,10 @@ void address_space_destroy(AddressSpace *as) { MemoryRegion *root = as->root; + if (as == &address_space_memory) { + return; + } + /* Flush out anything from MemoryListeners listening in on this */ memory_region_transaction_begin(); as->root = NULL;