From patchwork Fri May 20 15:51:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 9129859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 400D36048B for ; Fri, 20 May 2016 15:53:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3002B21BED for ; Fri, 20 May 2016 15:53:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24B2127CC9; Fri, 20 May 2016 15:53:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 7F2B121BED for ; Fri, 20 May 2016 15:53:34 +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 1b3miA-0007C0-3r; Fri, 20 May 2016 15:51:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b3mi8-0007Am-RP for xen-devel@lists.xen.org; Fri, 20 May 2016 15:51:36 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id B1/AA-06460-8823F375; Fri, 20 May 2016 15:51:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsXiVRvkrNtuZB9 u8PO4gsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvFu43amgkWiFddXrGRvYDzD28XIxSEk0M8o 8X3dDpYuRk4OFoGXLBKfH9qAJCQE+lklVi78wtTFyAHkxEi8uSQGUiMhUCYx48d/NhBbSEBd4 vS7HWwQg2YySXSu38kOkmATMJHY++cBE4gtIiAtce3zZUYQm1nAV+LmzuNgM4UFgiRWnuQEMV kEVCXef+AFqeAV8JD4vnQBC8RWOYkFF9JBwpwCnhLtK84xQmz1kGjZcZBlAqPAAkaGVYzqxal FZalFupZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBAVXPwMC4g/H1T6dDjJIc TEqivGri9uFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHhDDIFygkWp6akVaZk5wNCGSUtw8CiJ8 MaApHmLCxJzizPTIVKnGHU5tky9t5ZJiCUvPy9VSpw3AqRIAKQoozQPbgQszi4xykoJ8zIyMD AI8RSkFuVmlqDKv2IU52BUEua1BJnCk5lXArfpFdARTEBH3BKzATmiJBEhJdXAuLZEv9DmD4u SzIu0vp5HOWp7S+PclU5Wp+34tUW1TbChbXvCvHMWwUX/shZ8M/N59fohV4N3gH6ObulO542e Gptmx855bP+Jz/6Qa/+/Q5o/TnpeaL2Q87r14d9814bXJ/uyUlm6atfy+4m4vH50ti8nqKjZW idgpvDsZ1ofr+mVKV0+mHpFiaU4I9FQi7moOBEA8hmXc64CAAA= X-Env-Sender: edgar.iglesias@gmail.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1463759495!37331847!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36791 invoked from network); 20 May 2016 15:51:35 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-15.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 May 2016 15:51:35 -0000 Received: by mail-wm0-f67.google.com with SMTP id 67so7124254wmg.0 for ; Fri, 20 May 2016 08:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NHg2gOWm24bNsoUmwsyrDCQlifen3G0344WLbDfebWw=; b=tc7j4sVVKGudqa6eeI0p/KKgcCnZRJqMxZUMDtm+7R+t3wmtKIvzwaaV1+OTCZRNXu YbBdWCk7InQjo1BlY7PPf1dqakWBxDMOQ5T7OUVgzTqX8hgsVmKLQESvbDRRzA+yGCPb b8+LLIFyQ+DDiaVEtcyhxx4iFtxIHLITXp1wma8dXoOoz74wz+iOQqtjAjZg0f/xfg3t RKklHrNiEa7x49UGDsiTF9wQ/qINpIdsKRfeNyHDA8OhUF/kXKc0Cyuaf8ykIWelLHDM HWfi9fB1Phm6Ydme7z2iiZ0vm2K7rJnBHhLoXueWfkTFbyb6dACfQTqN5jMJN5ODPoRP z0TA== 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=NHg2gOWm24bNsoUmwsyrDCQlifen3G0344WLbDfebWw=; b=c8/x+i9k9ZSa37Yv8WttdiXvezltpRuqXvhbv4t6AY3wKjFaB319TLsO/j5cyx4b/w yOrNcsVzx127tJ/2idC4Cbfx1VvmVkd420SQ7zM2LaPxaCgTmBXkssounXZmBsYcXwhB 33gzS3IWmGs7BY+DIWQJkpuDkHGT0PhwzTRmGceO4yTWRCSc+wuh8BMSpW47zLiAAxml jtrluWic37fjf1hFeHw6duWStGmmTuOXfzHOOvUxOeFpCKoS66WhMxsoVL3RBUGGK7Of puuZVP2SI+F+66wH1k6trDg2OqzDGS+RYO976t6ln481Qd6c3RWUAreviXprPplQAOKy vI3A== X-Gm-Message-State: AOPr4FXfAeW/R7eZd860qAjolqgOo79SVNgym8ANXsL/Ewkm3+ytjbpGTUU+Ef73IbgsrA== X-Received: by 10.28.11.82 with SMTP id 79mr4468191wml.33.1463759495184; Fri, 20 May 2016 08:51:35 -0700 (PDT) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id xt9sm20369739wjb.17.2016.05.20.08.51.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 May 2016 08:51:34 -0700 (PDT) From: "Edgar E. Iglesias" To: xen-devel@lists.xen.org Date: Fri, 20 May 2016 17:51:26 +0200 Message-Id: <1463759488-11900-5-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463759488-11900-1-git-send-email-edgar.iglesias@gmail.com> References: <1463759488-11900-1-git-send-email-edgar.iglesias@gmail.com> Cc: edgar.iglesias@xilinx.com, julien.grall@arm.com, sstabellini@kernel.org Subject: [Xen-devel] [RFC for-4.8 4/6] xen/arm: Add helper functions to map RWX 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-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" Create a helper function to map regions as MEMORY with cached attributes and read-write-execute permissions. Signed-off-by: Edgar E. Iglesias --- 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 db21433..7e788f9 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1219,6 +1219,32 @@ int p2m_populate_ram(struct domain *d, d->arch.p2m.default_access); } +int map_regions_rwx_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_ram_rw, + p2m_access_rwx); +} + +int unmap_regions_rwx_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_rwx); +} + int map_regions_rw_cache(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 d240d1e..294050e 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_rwx_cache(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn); + +int unmap_regions_rwx_cache(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn); + int map_regions_rw_cache(struct domain *d, unsigned long start_gfn, unsigned long nr_mfns,