From patchwork Wed Jan 27 13:51:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8134421 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 045B79F818 for ; Wed, 27 Jan 2016 14:21:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 23A312024F for ; Wed, 27 Jan 2016 14:21:06 +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 2892C201DD for ; Wed, 27 Jan 2016 14:21:05 +0000 (UTC) Received: from localhost ([::1]:50647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQXi-0005da-2e for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jan 2016 08:53:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQW9-0002y5-UI for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:52:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOQW8-0002B3-Qb for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:52:17 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:33267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQW8-0002Am-Ew for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:52:16 -0500 Received: by mail-wm0-x232.google.com with SMTP id l66so3574465wml.0 for ; Wed, 27 Jan 2016 05:52:16 -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=iy2Lh3LNahIg+qoR9RWwNtC4G0viqPsEtsuTu51C5dyp+QkehDVpKSsJ68dtumPGVO oUb3vAwB+5gotHY2vRFfXXPB+vfI5vySQiOeLUkQCny0PiQYZc+eGL5cdrE7l/DjhbQD PikN6Vgwpm7NGIKe234v0riSgvWMLw9xc/yvE= 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=PkbO9B1+8OaqNVq6QDS1yTuiW3ez5+uG9JC3vGZyPJgVZxNkvOVn/RMG8dMTm+V7cl looIpEIYwurW0Lgx8g0aYlh3k5tI7o+hlrqYWPiSy964p71wFcaDmXxUf9pQiY8ENhbW RN9FPHw3kAb07XkUNHA+XMEmqWylq6td3E0llyA58wOalUQp0u1j3irvgFLEIQGHzAoy G2lCHgzRpOpLZrbAkfx1Isvo7cR+XZlXdxKAnMSoRTGa2ygAu6I8xii4wn0PrcCrqZV8 d+KdzTR+Nvl2cEqO3J35oAnK1O/ObatS/AppIHnZB2t8NAP+I1H5Rw1fqdB6PODBiAk9 FSoA== X-Gm-Message-State: AG10YOTh9HkPcYmHGhs4xdvmNzYHXSYdHTjLBYJlUgyzg3yAhgoe43vxogiHhkbXKNvfWHA6 X-Received: by 10.28.45.151 with SMTP id t145mr32148510wmt.88.1453902735782; Wed, 27 Jan 2016 05:52:15 -0800 (PST) Received: from new-host-8.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id t9sm6345866wjf.33.2016.01.27.05.52.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jan 2016 05:52:12 -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: Wed, 27 Jan 2016 13:51:53 +0000 Message-Id: <1453902715-25304-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453902715-25304-1-git-send-email-eric.auger@linaro.org> References: <1453902715-25304-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::232 Cc: Bharat.Bhushan@freescale.com, suravee.suthikulpanit@amd.com, christoffer.dall@linaro.org Subject: [Qemu-devel] [RFC 5/7] 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,