From patchwork Mon Oct 17 19:38:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 9380355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7FD6E600CA for ; Mon, 17 Oct 2016 19:43:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6934028C96 for ; Mon, 17 Oct 2016 19:43:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C7AC28E02; Mon, 17 Oct 2016 19:43:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0424D28C96 for ; Mon, 17 Oct 2016 19:43:37 +0000 (UTC) Received: from localhost ([::1]:35452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwDou-0005Ck-7F for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Oct 2016 15:43:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwDkK-0001IS-DH for qemu-devel@nongnu.org; Mon, 17 Oct 2016 15:38:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwDkJ-0007q5-GH for qemu-devel@nongnu.org; Mon, 17 Oct 2016 15:38:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwDkH-0007n2-3w; Mon, 17 Oct 2016 15:38:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 531FF624AA; Mon, 17 Oct 2016 19:38:48 +0000 (UTC) Received: from localhost.redhat.com (vpn1-5-170.ams2.redhat.com [10.36.5.170]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9HJcVFW009529; Mon, 17 Oct 2016 15:38:44 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, alex.williamson@redhat.com, pranav.sawargaonkar@gmail.com Date: Mon, 17 Oct 2016 19:38:25 +0000 Message-Id: <1476733110-14293-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1476733110-14293-1-git-send-email-eric.auger@redhat.com> References: <1476733110-14293-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 17 Oct 2016 19:38:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v5 3/8] memory: Add reserved_iova region type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: diana.craciun@freescale.com, Bharat.Bhushan@freescale.com, drjones@redhat.com, christoffer.dall@linaro.org, fkan@apm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new reserved_iova region type. This type of iova region is bound to be used by the kernel to map some host physical addresses (typically MSI frames). A new initializer, memory_region_init_reserved_iova is introduced, as well as a test function, memory_region_is_reserved_iova. Signed-off-by: Eric Auger --- include/exec/memory.h | 29 +++++++++++++++++++++++++++++ memory.c | 11 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 10d7eac..f97b1f4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -191,6 +191,7 @@ struct MemoryRegion { /* The following fields should fit in a cache line */ bool romd_mode; bool ram; + bool reserved_iova; bool subpage; bool readonly; /* For RAM regions */ bool rom_device; @@ -385,6 +386,21 @@ void memory_region_init_ram(MemoryRegion *mr, Error **errp); /** + * memory_region_init_reserved_iova: Initialize reserved iova memory region + * + * @mr: the #MemoryRegion to be initialized. + * @owner: the object that tracks the region's reference count + * @name: the name of the region. + * @size: size of the region. + * @errp: pointer to Error*, to store an error if it happens. + */ +void memory_region_init_reserved_iova(MemoryRegion *mr, + struct Object *owner, + const char *name, + uint64_t size, + Error **errp); + +/** * memory_region_init_resizeable_ram: Initialize memory region with resizeable * RAM. Accesses into the region will * modify memory directly. Only an initial @@ -573,6 +589,19 @@ static inline bool memory_region_is_ram(MemoryRegion *mr) } /** + * memory_region_is_reserved_iova: check whether a memory region corresponds to + reserved iova + * + * Returns %true is a memory region is reserved iova + * + * @mr: the memory region being queried + */ +static inline bool memory_region_is_reserved_iova(MemoryRegion *mr) +{ + return mr->reserved_iova; +} + +/** * memory_region_is_skip_dump: check whether a memory region should not be * dumped * diff --git a/memory.c b/memory.c index 58f9269..00a0ebe 100644 --- a/memory.c +++ b/memory.c @@ -1309,6 +1309,17 @@ void memory_region_init_ram(MemoryRegion *mr, mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; } +void memory_region_init_reserved_iova(MemoryRegion *mr, + Object *owner, + const char *name, + uint64_t size, + Error **errp) +{ + memory_region_init(mr, owner, name, size); + mr->reserved_iova = true; + mr->terminates = true; +} + void memory_region_init_resizeable_ram(MemoryRegion *mr, Object *owner, const char *name,