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: 12447347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF8E0C4338F for ; Thu, 19 Aug 2021 14:24:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 81A6461100 for ; Thu, 19 Aug 2021 14:24:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 81A6461100 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGiy4-0002Mk-Lf for qemu-devel@archiver.kernel.org; Thu, 19 Aug 2021 10:24:28 -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+qemu-devel=archiver.kernel.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));