From patchwork Thu Oct 6 09:50:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 678801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sqShy2J82z9rxw for ; Thu, 6 Oct 2016 20:56:18 +1100 (AEDT) Received: from localhost ([::1]:54358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs5PT-0002ak-9k for incoming@patchwork.ozlabs.org; Thu, 06 Oct 2016 05:56:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs5KU-0006y8-NO for qemu-devel@nongnu.org; Thu, 06 Oct 2016 05:51:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs5KT-0007F6-Q8 for qemu-devel@nongnu.org; Thu, 06 Oct 2016 05:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs5KP-0007Ch-Ss; Thu, 06 Oct 2016 05:51:02 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 5325F4DD79; Thu, 6 Oct 2016 09:51:01 +0000 (UTC) Received: from localhost.redhat.com (vpn1-6-233.ams2.redhat.com [10.36.6.233]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u969okS3016130; Thu, 6 Oct 2016 05:50:58 -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: Thu, 6 Oct 2016 09:50:40 +0000 Message-Id: <1475747444-12552-5-git-send-email-eric.auger@redhat.com> In-Reply-To: <1475747444-12552-1-git-send-email-eric.auger@redhat.com> References: <1475747444-12552-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 06 Oct 2016 09:51:01 +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 v3 4/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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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,