From patchwork Fri Jan 29 16:53:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8165021 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 437BCBEEE5 for ; Fri, 29 Jan 2016 16:56:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F3A020328 for ; Fri, 29 Jan 2016 16:56:27 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id E06BC20253 for ; Fri, 29 Jan 2016 16:56:26 +0000 (UTC) Received: from localhost ([::1]:35321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPCLS-0005U2-Ao for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jan 2016 11:56:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPCJK-0001xA-He for qemu-devel@nongnu.org; Fri, 29 Jan 2016 11:54:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPCJH-0003zw-4R for qemu-devel@nongnu.org; Fri, 29 Jan 2016 11:54:14 -0500 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:38660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPCJG-0003zf-Pz for qemu-devel@nongnu.org; Fri, 29 Jan 2016 11:54:11 -0500 Received: by mail-wm0-x235.google.com with SMTP id p63so76300352wmp.1 for ; Fri, 29 Jan 2016 08:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OWv/2//g5AYghjzg3bRGTTFY1I/sd5ewy4o6R2cO2CM=; b=S48kcVPIiUSIZz3l33cC+ygjqRoybRtHZYbkGLgwiyxWg8B2gfuE8l8114ZFZxRT1x jdqfsoY70n6hckqg4FuXV2ZWIM0fzJNZFxsQ8yQWdG4IZApTJGIW03PeFypNHT55EK9T e/YWdBKdX2q8CvCbtXspw8snQWDpNuD7KcOG8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OWv/2//g5AYghjzg3bRGTTFY1I/sd5ewy4o6R2cO2CM=; b=Wf3DuquwccWlUuB9Rh/X+M2jU/GLufjNf3chQVDVZzaUS78F/WJAML32f2qAHiJWOP ph1L/LkSSv2MN7TlzMvE/zD9OFcaEQRxb7ocPFZez0dFM+myZHVwWjXYL9iEqSKwwvSx 4QU1SDHktHl2FZfKsXf7yyEVzqCpvGEbXTU3Uc3c0QrUYKLJNw2f1yztDLfdm8tm4U94 aQhSzjky13Lgbz23cbchZEgL7JR+9fdHRoBNmu++14OhkS9g2NhudnkxQcwzGOPUoKvZ ZQoVr4HNswOfrfS9WUmfJIvArBSkEvDxO+JFsWuseuxrc86PW782Uu/QGnHbZZjc3a9M Wt/w== X-Gm-Message-State: AG10YOTFIMWjPvTWpnxV0cH/lMcXCld5AZ7s/V72U2RA7Rkkclk1nd+QIsy5xP5mhvejZRrW X-Received: by 10.194.22.101 with SMTP id c5mr11036477wjf.151.1454086450170; Fri, 29 Jan 2016 08:54:10 -0800 (PST) Received: from new-host-12.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id ei9sm16415530wjd.40.2016.01.29.08.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jan 2016 08:54:08 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, alex.williamson@redhat.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, pbonzini@redhat.com, agraf@suse.de Date: Fri, 29 Jan 2016 16:53:46 +0000 Message-Id: <1454086429-4373-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454086429-4373-1-git-send-email-eric.auger@linaro.org> References: <1454086429-4373-1-git-send-email-eric.auger@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::235 Cc: Bharat.Bhushan@freescale.com, suravee.suthikulpanit@amd.com, christoffer.dall@linaro.org Subject: [Qemu-devel] [RFC v2 5/8] memory: add reserved_iova region type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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. 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 c92734a..616cb86 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -165,6 +165,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; @@ -359,6 +360,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 @@ -531,6 +547,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 d2d0a92..d9ff1b7 100644 --- a/memory.c +++ b/memory.c @@ -1231,6 +1231,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,