From nobody Fri May 17 07:07:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629382959921449.67526945509314; Thu, 19 Aug 2021 07:22:39 -0700 (PDT) Received: from localhost ([::1]:53730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGiwI-00053u-ST for importer@patchew.org; Thu, 19 Aug 2021 10:22:38 -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 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 Received: by mail-wm1-f70.google.com with SMTP id e12-20020a05600c218cb02902e6bbacdcd1so1595719wme.4 for ; Thu, 19 Aug 2021 07:20:47 -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) 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= X-MC-Unique: 33ttK-Z1PhOGwVoWGDp0eA-1 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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1629382961793100001 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=C3=A9 --- 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) =20 void address_space_init(AddressSpace *as, MemoryRegion *root, const char *= name) { - memory_region_ref(root); + if (root !=3D get_system_memory()) { + memory_region_ref(root); + } as->root =3D root; as->current_map =3D NULL; as->ioeventfd_nb =3D 0; --=20 2.31.1 From nobody Fri May 17 07:07:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629382856; cv=none; d=zohomail.com; s=zohoarc; b=hpfgDLlkkhZTlPIt1ZCCIrOjl8y+x8cL/SrzFzSyky3ocLBwp2QfS6WaF+cjB9t3IDciUuNvxcS8y/y0RemaZlV8f4opfU39opCoE/Dki0PsncLvK/87B2NjYGQ3Treup3bwF6SmSLIK4VzgBf3Dwgqe6XJ+VDwyVEv+o4vYO7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629382856; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=S5J953m8jthIx8YKw7RXWxnSJEtO9PzEi6CmU+gZmWk=; b=bdyuYc28ZKlh0OM6bC9aDLRpHtncsf7ymQHljCQYavPySjT+VsjivdcjnnQdolXzfOVclxiVsUL+kD1F+G6SniXhpCneVWoM9swj0sSs6phScgMWfaP8UBcfv2GZ+adM/IY9gfCSgyFDGe1HtpzEAUTTa7CYA194+BSuxi/9FSk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629382856083838.5602177158132; Thu, 19 Aug 2021 07:20:56 -0700 (PDT) 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-468-4Qo4jEhBNFaD_4wkuwSOBA-1; Thu, 19 Aug 2021 10:20:51 -0400 Received: by mail-wm1-f69.google.com with SMTP id m13-20020a7bcf2d000000b002e6cd9941a9so3558010wmg.1 for ; Thu, 19 Aug 2021 07:20:51 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382855; 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=B2nXs2/wnXkL8ocPPSKkwFP/eU0ogdX7ruMTgb/Sk6bpVNgY7sgo8ymDtst7DXBGI2FfdU p0LcqK4bcbteHVwZIuyTAVIYgweoXmaw0MZuBGiZHoWlFAdZHLImpyJifSPA7JgCvKRSRE GgddaWTs6+D2fxmWGRH8KIYaA91HjO8= X-MC-Unique: 4Qo4jEhBNFaD_4wkuwSOBA-1 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=d50vJx4Y6KxzqBNdEr4tnTUt+UfKMMzIZgaoys2Kgfzt7a68P9PEnv4NAEG3uE1Wqt Kj/r8q6mXz01kR9k/uHt3jMxRoc3UK5wpv+SpYoF7gTPhYM+CuJOhcB76FvFvDerY1OP QLj8a14g1apDQxfORLXSUPl8qnhyGg+zN/M/JwfEo5Z6bTMgv3xU/lxoVKYOAUD1SYTv ttHFWcvJUla2RXGxhxwrzSxsfPW06pEZGrdRd1RhT/K6SAE9AetVIIVrhgwG1v+ScnDP RWi6BJy+G+z9M609dzRWSOG0iAdr90m35MlbV9m3Ie7TN/VtBE0yKlPcDk5GfxmgSS3/ mGhQ== X-Gm-Message-State: AOAM533AHRDIRXPRE1HXRu2rsQjNUSiP4wG1h6Fjd5Blb38AlJBPsZRz 9Tyy0T875GZQBwL1KlCZ3CrIkl7cAiJYf8MZIUcLTh20SpTKn7GkYBBMHnJLAXB9QJvzVQZf12o GzPUC6D4I6zZBow== X-Received: by 2002:a7b:cc16:: with SMTP id f22mr13857452wmh.99.1629382850592; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Alistair Francis , Jianxian Wen , Mark Cave-Ayland , qemu-arm@nongnu.org, David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629382857026100001 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=C3=A9 --- 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(MemoryRegio= n *mr, */ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *= name); =20 +/** + * 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, MemoryRegi= on *root, const char *name) address_space_update_ioeventfds(as); } =20 +AddressSpace *address_space_create(MemoryRegion *root, const char *name) +{ + AddressSpace *as; + + as =3D 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)); --=20 2.31.1 From nobody Fri May 17 07:07:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629382860; cv=none; d=zohomail.com; s=zohoarc; b=Fg3G+/suKXy1mpdMqEvPNqx3xqoq+t3yGeMeOTD4flukuZaqkoROccsCHifOk6PNNjDDOiwdw0ztwHa25ltb5M67cO0IKgEi/cBoghG9wQORNzFVaedzPEkv7LmGSu/YUT1kZlXlvkLfxkLnM+TiTpYDBl3rFxdnk2aj0U07eac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629382860; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=shIeo+L4trmRqnGxLVVjByJ3DfeCv4gt22CJ/6RIBwg=; b=Vhk1KW1APkRVqvya3OMvn9G5u6EiiFZkwAeYie9yiBWX6U/jYYcPpLbVe1rVmPpwhKm6YitfOzVsgT1mHl+Wb2jL+/1O75hYw+nuU99vLFxPecg89iSDY36JjVyhjheM8BYbFCby3WaTLudZ7ZKFPYCC83GYQcusxNKrrphQvl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629382860991448.70422697574645; Thu, 19 Aug 2021 07:21:00 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-3AWoLIbNNHuNWwWAXsXxeg-1; Thu, 19 Aug 2021 10:20:56 -0400 Received: by mail-wm1-f72.google.com with SMTP id 10-20020a05600c024a00b002e6bf2ee820so3544224wmj.6 for ; Thu, 19 Aug 2021 07:20:56 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382859; 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=QCfMQ7HhoTzNzjTjguzytE9SK4AOel/yijUQn8/CVr2dNucd/gXRr1kRZYOHSX/+Z8CZEL BzUvitcqIi9EQ4ElE++ei4igjAlktGz6+921iP76WdYqrUEx21Gyxs+pwW8wZOFN1jw56d X6tOOyebwetxKdzUAOIJwawHogQHGIc= X-MC-Unique: 3AWoLIbNNHuNWwWAXsXxeg-1 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=AQ5KTj7jzJOhZxEaF7KdJ+A99JxYO/43U12cmUZQcjPn1/Ka59iCxzefOQjkdr1gSe mMSYim67QH9Uej7fQqeMuhQEmqjQV2iYm9FG+RZ9dvqKj5kxFnSDcsMn/wJ4ejV9qTuv 6/T5JER+moGGUYtzIBQeDnUmM+MJQ4rtzWQmcpWfTPbV5bkRubZATxIn6Dk4fA8d00zA X+AxD125+M5rolV6vk5oN6FFs7Okq6Ezrx+QhuGMZDWZS/eCxuTCMsIiCm3ManNNlMHS DyjnyJf5iKxMVnlaoTbap4LDlbjpZUd+FMn9uYm4iwf0iXApK+GdR9aMMbMfCkmYoqVW 43QA== X-Gm-Message-State: AOAM531XDGkk+YaapG7axcOyImzKp/srcg74oPKx2tX2h7tn/02KtOXc FPEVdCX3BDTEOtyr/jNcPDqMfk0JlOW+82H3h3BAIvbFzAl9BNQ3ldyj2Z233wB1Zvyda7bDFqk zeIbOyWcAIa3l6Q== X-Received: by 2002:adf:fcc5:: with SMTP id f5mr4361094wrs.114.1629382855504; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Alistair Francis , Jianxian Wen , Mark Cave-Ayland , qemu-arm@nongnu.org, David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629382862943100001 Replace g_new0() + address_space_init() by address_space_create(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D g_new0(AddressSpace, 1); + AddressSpace *as; char *as_name; =20 assert(mr); as_name =3D g_strdup_printf("%s-%d", prefix, cpu->cpu_index); - address_space_init(as, mr, as_name); + as =3D address_space_create(mr, as_name); g_free(as_name); =20 /* Target code should have set num_ases before calling us */ --=20 2.31.1 From nobody Fri May 17 07:07:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629382868; cv=none; d=zohomail.com; s=zohoarc; b=LJiua3sLMQSpyFv+2TqRbPxjdB04LeEmBE4jFGMTWKsfEvfQaXIealBtOFLmb6zPOoMWCga07pYl+5snfqHFDs7mLa4v94c0JdGDKqc09clPPm9A+Y7g43EKjg0/foft4hVSmnY8gydIc2tIDkpO1a0JUZsTPNz6fu/iN9Pg4Mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629382868; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=zZLP80M+KMpFzOA/bjjaS/ry2kFipBSjMsh/PACigbc=; b=gBIMYSpW/+JxGfeTbPO8DqJzRXJbDof4eq0itz3GEtptiaBkOQNEHgbRnFf/a0FiihPzP5Yj1PUmZYM3L4gXXAxHw7EVeum+MOIzbzHP2lpdM3CWBjj/NkdSc5ABT447jK0Ux1xn66vp3NMjm6QHkDNK6UY/tyn96uarusEuE3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 162938286822292.45395538752734; Thu, 19 Aug 2021 07:21:08 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-myPyzLiMP_CK1k8Edq__Dg-1; Thu, 19 Aug 2021 10:21:01 -0400 Received: by mail-wr1-f70.google.com with SMTP id d12-20020a056000186cb02901548bff164dso1746967wri.18 for ; Thu, 19 Aug 2021 07:21:01 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: myPyzLiMP_CK1k8Edq__Dg-1 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=DR6vXJuwHVnvY8F/uxA67VjjqWoro0d+4xoJT/wSOE6/9lTpnLsY7L30EzwD0ip9fV I76voo4rfm4y2puB6oeJuW399fv+S9/Y87Xk2fKeZ+gXnqFU1sF5WYMnva16gLJWo1cg 8fyKDTD4at1Fpuba9uC0//oduq8BmUWV9MEA3qgP9ZUOMAAzLGL5InUK5/MKYJmH9BO8 59BqRrgFGH2fjPeBzVyXIcxtxKuRkiQRzC3j55T10sUUo2EwgJns70rEUREPqsqxX27I IWqed2HkZFHI5OmY5zE/eoFDbpFgL0IXIj2FiAyEWlekDuM3OV3XYspJRrA79xzeyo3i 39PA== X-Gm-Message-State: AOAM531MEqd+8XjpXTtgmqeGQFC3hqjIdmmyw9+ZNldk8ZiT2bZ98ry1 fOgj3BXLi9svJv8rlwWOF1sJcseSblddA17dEuM/Jnu42uTGPh8xnKvUWGT05cx1SR9f6tNnvd4 gR7cMTu+HJhHpFg== X-Received: by 2002:adf:fb8d:: with SMTP id a13mr4371225wrr.164.1629382860159; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Alistair Francis , Jianxian Wen , Mark Cave-Ayland , qemu-arm@nongnu.org, David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629382869165100001 Replace g_malloc0() + address_space_init() by address_space_create(). Release the resource in DeviceUnrealize(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 **er= rp) }; } =20 - if (s->dma_mr) { - s->dma_as =3D g_malloc0(sizeof(AddressSpace)); - address_space_init(s->dma_as, s->dma_mr, NULL); - } else { - s->dma_as =3D &address_space_memory; - } + s->dma_as =3D address_space_create(s->dma_mr ?: get_system_memory(), N= ULL); s->attr =3D MEMTXATTRS_UNSPECIFIED; } =20 +static void zdma_unrealize(DeviceState *dev) +{ + XlnxZDMA *s =3D XLNX_ZDMA(dev); + + address_space_destroy(s->dma_as); +} + static void zdma_init(Object *obj) { XlnxZDMA *s =3D XLNX_ZDMA(obj); @@ -827,6 +829,7 @@ static void zdma_class_init(ObjectClass *klass, void *d= ata) =20 dc->reset =3D zdma_reset; dc->realize =3D zdma_realize; + dc->unrealize =3D zdma_unrealize; device_class_set_props(dc, zdma_props); dc->vmsd =3D &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, Err= or **errp) s->src_timer =3D ptimer_init(xlnx_csu_dma_src_timeout_hit, s, PTIMER_POLICY_DEFAULT); =20 - if (s->dma_mr) { - s->dma_as =3D g_malloc0(sizeof(AddressSpace)); - address_space_init(s->dma_as, s->dma_mr, NULL); - } else { - s->dma_as =3D &address_space_memory; - } - + s->dma_as =3D address_space_create(s->dma_mr ?: get_system_memory(), N= ULL); s->attr =3D MEMTXATTRS_UNSPECIFIED; =20 s->r_size_last_word =3D 0; @@ -665,6 +659,7 @@ static void xlnx_csu_dma_unrealize(DeviceState *dev) XlnxCSUDMA *s =3D XLNX_CSU_DMA(dev); =20 ptimer_free(s->src_timer); + address_space_destroy(s->dma_as); } =20 static const VMStateDescription vmstate_xlnx_csu_dma =3D { --=20 2.31.1 From nobody Fri May 17 07:07:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629382872; cv=none; d=zohomail.com; s=zohoarc; b=kk3Nb6w0DqSfIXauDrAcB+En1+fRS1Fh4spUCWbu4FC3gcgX0Wj1Unng1mcqztlZL/ZUCZHBqwccV8J6ceiPTJh5ALERoLqvNtRxqbzUqignpL5j0ETVH/bGl1bkOTkDzVQdVD3/beRf9y4s8FT67A+7JLrSXfk+OldSq8XxLOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629382872; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=WwxcFzkUhr+SPEjC7KEdcFzv7DLvVmTT/gW/kFoiXv4=; b=Xpi9RNfM3MlFKTK1MxdDKEB+/Yx2QgqVfAiMVZfeEOGLYJ1TqA7AmugJNSlQbbbgS0YeyeIeOn+RA6QzLMzRuFelCSr5QJ/qfjM8OZc5C8CQvHhk0QeNiH5xZ8y5EEDV/Cnh7XOpUJXLR6KUNmNsXS0OTkAgFvNxmvuX6KLGVxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162938287198448.55521981470156; Thu, 19 Aug 2021 07:21:11 -0700 (PDT) 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-528-POr2aJVFP8SbN686BpgCNQ-1; Thu, 19 Aug 2021 10:21:06 -0400 Received: by mail-wm1-f70.google.com with SMTP id r11-20020a05600c35cb00b002e706077614so1315120wmq.5 for ; Thu, 19 Aug 2021 07:21:06 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382868; 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=MvjTmNo62YtyxpBhoR2k9fBmedifYZ/vokz4MhVM+dSGD0PJ4p0q8e++vz7Nb2Dkq/yz4G sESFl7zkrusmitIiX0kh0eGvIvt80jW/L+Mff6ENoLAnxw4//DO4qzla8RPB7nfEk1WGOw SgMIIOnun/D+3xXbNxpfAOEsQoahHaY= X-MC-Unique: POr2aJVFP8SbN686BpgCNQ-1 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=QWeCtJ58Gwooxqg9omkg6K2JGYhFgoDYoqWiUehEnBlcLzhwfJ4diVfWPzRf/0pP3p UEZH1w3yyS+6NXb4KBAC1qYCvfg1R3JnJOYhzGOxKno3+yfpK3jXYnT1K95OESDeQGMz gL8L2thD/sBxtNhZIdln3PvPZnVhAEYP1fyk9sOxTiTYVrUVkx6qAhcIqt0c172G6ADq opJV7rmMFHMeH2Cis5l0wmYyA6fi2OIEdrZk0Q6hyrv6ilqNxMiphqjfJ7WFMJL7PnuB cTvB3NgA+VDfJnlrA25GZcxY/hSLH21Ke2qwmQYhI6lJaD3F0J/pzN8VVwBWIksqgMy5 0znQ== X-Gm-Message-State: AOAM530O/vGtceLMxte+XJ5lL7e30Cg7L0Ff7pVhwFwHnQ5dzYFD8t0U +84edpqiBr9FplquM1WDTx8UESW0aWG5KcDpAvTAv2W3Uu4+hA2fH/e7rmr+npJWo3KFejowMqg Fh7Grc2EoSqbRog== X-Received: by 2002:a1c:2090:: with SMTP id g138mr14014782wmg.98.1629382865447; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Alistair Francis , Jianxian Wen , Mark Cave-Ayland , qemu-arm@nongnu.org, David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629382873687100001 Replace g_malloc0() + address_space_init() by address_space_create(). Release the resource in DeviceUnrealize(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D 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 =3D g_malloc0(sizeof(AddressSpace)); - address_space_init(s->xhci.as, s->xhci.dma_mr, NULL); - } else { - s->xhci.as =3D &address_space_memory; - } + s->xhci.as =3D address_space_create(s->xhci.dma_mr ?: get_system_memor= y(), + NULL); =20 sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->xhci.mem); } =20 +static void xhci_sysbus_unrealize(DeviceState *dev) +{ + XHCISysbusState *s =3D XHCI_SYSBUS(dev); + + address_space_destroy(s->xhci.as); +} + static void xhci_sysbus_instance_init(Object *obj) { XHCISysbusState *s =3D XHCI_SYSBUS(obj); @@ -103,6 +106,7 @@ static void xhci_sysbus_class_init(ObjectClass *klass, = void *data) =20 dc->reset =3D xhci_sysbus_reset; dc->realize =3D xhci_sysbus_realize; + dc->unrealize =3D xhci_sysbus_unrealize; dc->vmsd =3D &vmstate_xhci_sysbus; device_class_set_props(dc, xhci_sysbus_props); } --=20 2.31.1 From nobody Fri May 17 07:07:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629382916; cv=none; d=zohomail.com; s=zohoarc; b=J3XP1msDx/BBNzJwAXeD0/0m5fQC+pPMnCvXXfUI2IkSyEMBSCQzRJBczdxpcYufyXCfNe5ZIxgQ8E7VoLI6wm9DO97x22ukl9s0hPrhYUP72xabHC9xnOLuEdJV8sxeVR7fYu7RJ/X0Yhavt5nT04cBWTe8MgX+67j1K76jSvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629382916; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QEyWPjQ7Gf9BUPz8WL5PzOlCAdvMwlwVzwTeHocd/5s=; b=CDb6TOUckUYH2ANC2rgITuCSBIUSr+BQP5CX/3CzdfcLCq2BFBrXACUDrqbJg4IZnvjdITNACcFb8Tlh9cvD+e2sSCQPsmw+Tlma2FnkliNP9594VNZJTgP45MI7Vc+Jk6itLsfD5FG6Bkvp6XU0YPFHsFOJt85RRhMa3co3bIQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629382916573549.5604276373417; Thu, 19 Aug 2021 07:21:56 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-pW5yKX_GPFSXJ6dwhgE7SA-1; Thu, 19 Aug 2021 10:21:11 -0400 Received: by mail-wm1-f72.google.com with SMTP id n20-20020a05600c4f9400b002e6dc6a99b9so1598585wmq.1 for ; Thu, 19 Aug 2021 07:21:11 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629382873; 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=FoK9EqRe48oGYdYyDBKuQjcsLHvFfHXxHeBtmqoKUp9+133CpZhSgmWmX9sGzeyP8I5d00 ZnjqoyScpPQTs5gJBCWZfXnI/TQT6oVm6UnyY+vYWGKtM2KQXn6yib7MdR81/LJGJyT8GR 0KpbO242qErEgLqFc/zaGmxv5tNjalI= X-MC-Unique: pW5yKX_GPFSXJ6dwhgE7SA-1 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=iYmmG2yqN1I6VlGpj9QoN4EJ2cwhV6MqYd1Ww1ahUkRD/iVG5eV6TYkBaD7JoOKysT q8lokwwZjz5umwl2lhHELKS9OieowafcTVfJnx2V4OZuptNNwj1YtYtrm2g90+k8/OGB RZ2r2lOPWyYXD3w7BO7pZ9dsY3PObZdGVDRG+GLFuEFhXrxQDEoX5v/ACaD/KtSDvGAz WIbzN4X0fU3kJGQJC0F/OEb4xd03FOnlN4GtNdf0puJdNOCsNdn8dW2jvlcpnqGGoL9K PyH+3tzLGf8XVuLMMpFuSAIGD4mRa1GEgk05meZtEoiPi8mRhpVk8HH+5ch2ns7YnxyG hMLA== X-Gm-Message-State: AOAM531DjZE1f5dE8ipMTbnEBrIkjZm2YZZ9Vhnam57ky3bD2zceX3tV q2hv/RCRJCM7usrmmLSZAQmKn3lT/L+l4RVkLyGsLNropiTejN/EAP2yi27/iJ8TozkZonRsKlT Sp6Tps8dZXh86FA== X-Received: by 2002:a7b:c756:: with SMTP id w22mr13968324wmk.169.1629382870381; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Alistair Francis , Jianxian Wen , Mark Cave-Ayland , qemu-arm@nongnu.org, David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629382917953100001 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 ra= spi3b 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-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-periph= erals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ra= m-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-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-periph= erals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ra= m-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-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-periph= erals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff address-space: dwc2 0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu 0000000000000000-000000003fffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 0000000040000000-000000007fffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-periph= erals @bcm2835-peripherals 0000000000000000-0000000000ffffff 0000000080000000-00000000bfffffff (prio 0, ram): alias bcm2835-gpu-ra= m-alias[*] @ram 0000000000000000-000000003fffffff 00000000c0000000-00000000ffffffff (prio 0, ram): alias bcm2835-gpu-ra= m-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=C3=A9 --- 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 *roo= t, const char *name) { AddressSpace *as; =20 + if (root =3D=3D get_system_memory()) { + return &address_space_memory; + } + as =3D g_new(AddressSpace, 1); address_space_init(as, root, name); =20 @@ -2961,6 +2965,10 @@ void address_space_destroy(AddressSpace *as) { MemoryRegion *root =3D as->root; =20 + if (as =3D=3D &address_space_memory) { + return; + } + /* Flush out anything from MemoryListeners listening in on this */ memory_region_transaction_begin(); as->root =3D NULL; --=20 2.31.1