From patchwork Tue Nov 17 09:40:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7635031 Return-Path: X-Original-To: patchwork-linux-arm@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 1807DBF90C for ; Tue, 17 Nov 2015 10:10:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F824204D9 for ; Tue, 17 Nov 2015 10:10:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1B0F204D6 for ; Tue, 17 Nov 2015 10:10:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZydBF-0001Cq-E3; Tue, 17 Nov 2015 10:08:05 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zycs7-00032L-2L for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:48:22 +0000 Received: by wmvv187 with SMTP id v187so217954042wmv.1 for ; Tue, 17 Nov 2015 01:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eULshnREfaTKbHbrbExBcF7MO/pVNdjO9Z5s94irjwY=; b=d4alhwn/1SlBCvC621PxYaF3fnyLzMjMWqK7DEcnnki7NvqCHoh2pYbnfmE6tMk2rr +TN/lCKvUw1L5B9lHwvZAp9uX4AvMFCvr0CbpTdWG8DX7vLT/Yc64mV1ra5nos43Hcpo oHb59jhkcIILfddnSrvxLsmMHPm05bBTosn2W3z/JLA8VRs4mUj2h6aGZrP9qXLKfg6j qTizUifGBv/kiArWPQyE9mGUoTqulbjS6PSLreCabB9fm32kflXQNV9eL5B2EV5zwAuF zYLpea3Vx4Ta88WZlWrQohoyGXS6h9Hzgk01AC+8Pug8UDPZNC/Y2WAcEnY+fMyqhB00 QzCw== 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=eULshnREfaTKbHbrbExBcF7MO/pVNdjO9Z5s94irjwY=; b=SH1P86XjiWYG+q5gSzsDTjqt7ByuQEYUtR24RSjqPaB3X9534/8U5R1Y8Rs3Og5N8+ SWKTKp8S4q7QaRpN2VTpY1lOP09GVu0CdmrDtxZ6nt05ArEMuESQtbozO7h35l0ZN5Df IklNp4qNbFUipNdkjKeE3dSyLmYVrbfU5TWOBW0S1J8qiPBoKsXRFZQ3NO03FTC7GVy1 pcWds6R/nM3HNKzCe8kAoKw3CmGszESms/gsXuT2mQxqmUeDUxajhBr92dxS9dUZ6Chl WLPacUEUWTEBMrTU+tLSBJBwKY5ArDrsG1ApZaQMqGvFvPEBvxW+3tWUIHo9JGAS82DB l3Kg== X-Gm-Message-State: ALoCoQl6NcZRDjWTCkSoArMry4aWY6/rjxch72Y/RHuUxj24oiiGSEHbZQAwi3rVKobWdTmKxAKH X-Received: by 10.194.91.234 with SMTP id ch10mr49001999wjb.69.1447753677599; Tue, 17 Nov 2015 01:47:57 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id k133sm15279305wmg.18.2015.11.17.01.47.55 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:47:56 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Subject: [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions Date: Tue, 17 Nov 2015 17:40:46 +0800 Message-Id: <1447753261-7552-48-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_014819_664940_C1F07E92 X-CRM114-Status: UNSURE ( 9.01 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 From: Parth Dixit Create a helper function for mapping with cached attributes. Signed-off-by: Parth Dixit Signed-off-by: Shannon Zhao --- xen/arch/arm/p2m.c | 26 ++++++++++++++++++++++++++ xen/include/asm-arm/p2m.h | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index e396c40..7a108d8 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1140,6 +1140,32 @@ int p2m_populate_ram(struct domain *d, d->arch.p2m.default_access); } +int map_regions(struct domain *d, + unsigned long start_gfn, + unsigned long nr, + unsigned long mfn) +{ + return apply_p2m_changes(d, INSERT, + pfn_to_paddr(start_gfn), + pfn_to_paddr(start_gfn + nr), + pfn_to_paddr(mfn), + MATTR_MEM, 0, p2m_mmio_direct, + d->arch.p2m.default_access); +} + +int unmap_regions(struct domain *d, + unsigned long start_gfn, + unsigned long nr, + unsigned long mfn) +{ + return apply_p2m_changes(d, REMOVE, + pfn_to_paddr(start_gfn), + pfn_to_paddr(start_gfn + nr), + pfn_to_paddr(mfn), + MATTR_MEM, 0, p2m_invalid, + d->arch.p2m.default_access); +} + int map_mmio_regions(struct domain *d, unsigned long start_gfn, unsigned long nr, diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 08bdce3..b6215f9 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -158,6 +158,16 @@ int p2m_cache_flush(struct domain *d, xen_pfn_t start_mfn, xen_pfn_t end_mfn); /* Setup p2m RAM mapping for domain d from start-end. */ int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end); +int map_regions(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn); + +int unmap_regions(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn); + int guest_physmap_add_entry(struct domain *d, unsigned long gfn, unsigned long mfn,