From patchwork Fri Mar 25 13:48:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8671611 Return-Path: X-Original-To: patchwork-xen-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 A6059C0553 for ; Fri, 25 Mar 2016 13:51:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2C1D20351 for ; Fri, 25 Mar 2016 13:51:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D177220340 for ; Fri, 25 Mar 2016 13:51:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7g-0001IP-Bo; Fri, 25 Mar 2016 13:49:56 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ajS7e-0001GR-DZ for xen-devel@lists.xen.org; Fri, 25 Mar 2016 13:49:54 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 8A/71-30565-10245F65; Fri, 25 Mar 2016 13:49:53 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-3.tower-27.messagelabs.com!1458913791!33482745!1 X-Originating-IP: [209.85.220.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11617 invoked from network); 25 Mar 2016 13:49:52 -0000 Received: from mail-pa0-f45.google.com (HELO mail-pa0-f45.google.com) (209.85.220.45) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Mar 2016 13:49:52 -0000 Received: by mail-pa0-f45.google.com with SMTP id tt10so47126424pab.3 for ; Fri, 25 Mar 2016 06:49:52 -0700 (PDT) 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=4y8BbF1yYASZMzpSu8MQB0/4FBi6lMG9ygfpZ4rfBy8=; b=Xs1tnfmyq9IvNadd7AkUOG9lGShAys7tmNDUhzd0rE1L3p1KjjdwBE4AfMw0YBHRl4 DHl06d3u5RepKE+Apy/E6ycpZ5XN4bcyzd4t++wifkFIuStSG8PF/2ghqykAyKcRb2im REuUTgq1JShaRooVujarabOB9RcwixT2VQXRA= 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=4y8BbF1yYASZMzpSu8MQB0/4FBi6lMG9ygfpZ4rfBy8=; b=KYf4J+H8wez45fip/3bWwAZuzckg0RoYnlx8ksnX6u2PbvB0QbPCy0yVMQrWvizvue ABIpBaMM3CAS75HJi83KZniNkYD9bXk0bY8z+QUzfjSUfzU3zrxWU2fpMh/vGlSORxd+ ZmBR3DVVle/Fo3l+m876u9FpbZrNe3K2ruRZvNke5LcI5NbqE3j5xV4yuuQw3qQwXBap TUqY1rlqjfVrjP9hbMX7l+8s/wTGyGXIpSS1yOszjNSmi2NvO5DRXZs5VTXmHEUWlvtu oDUKCzVaXE2E63CNcvTpmrkQtskOQfvTRQ9D7HshG6OvkY264hOs6zvo/ebXIkeR6Zmh H56A== X-Gm-Message-State: AD7BkJLr6gbS4bNL0qnqyxztkujPLt4r54I6Q10jxzx/fNxa6kVAMymRCNbThMX5eVvQh58S X-Received: by 10.66.255.39 with SMTP id an7mr21263643pad.2.1458913791117; Fri, 25 Mar 2016 06:49:51 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.2]) by smtp.gmail.com with ESMTPSA id w20sm16744178pfi.31.2016.03.25.06.49.46 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 06:49:49 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Fri, 25 Mar 2016 21:48:42 +0800 Message-Id: <1458913735-2678-10-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458913735-2678-1-git-send-email-shannon.zhao@linaro.org> References: <1458913735-2678-1-git-send-email-shannon.zhao@linaro.org> Cc: peter.huangpeng@huawei.com, julien.grall@arm.com, stefano.stabellini@citrix.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, Parth Dixit Subject: [Xen-devel] [PATCH v7 09/22] arm/p2m: Add helper functions to map memory regions X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 and read-write range. Signed-off-by: Parth Dixit Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini Acked-by: Julien Grall --- v7: rename to map_regions_rw_cache --- 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 a2a9c4b..7e5f5d1 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1218,6 +1218,32 @@ int p2m_populate_ram(struct domain *d, d->arch.p2m.default_access); } +int map_regions_rw_cache(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, + p2m_access_rw); +} + +int unmap_regions_rw_cache(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, + p2m_access_rw); +} + 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 433952a..55626b4 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -144,6 +144,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_rw_cache(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn); + +int unmap_regions_rw_cache(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,