From patchwork Mon Jul 4 11:45:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9212429 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 AA19260572 for ; Mon, 4 Jul 2016 11:49:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E0BF286DE for ; Mon, 4 Jul 2016 11:49:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80BFB286E4; Mon, 4 Jul 2016 11:49:28 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 DC713286DE for ; Mon, 4 Jul 2016 11:49:27 +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 1bK2LK-0008KB-Tx; Mon, 04 Jul 2016 11:47:14 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bK2Kc-0007zb-Ad for xen-devel@lists.xenproject.org; Mon, 04 Jul 2016 11:46:30 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 1F/3F-22092-59C4A775; Mon, 04 Jul 2016 11:46:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsXSPJ+BQ3eqT1W 4wZf1Qhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8baU0cYCx4pV9w7eomlgfGmdBcjF4eQwEZG ibuHZzJDOMsZJe7fuwvkcHKwCRhITHm9khXEFhFQkri3ajITSBGzQBOjxL3GB2wgCWEBb4n7R /6B2SwCqhJX13wDsjk4eAVsJTZdjQAJSwjISUxefIkRxOYECjd0fGICsYUEbCS67z5mm8DIvY CRYRWjenFqUVlqka6hXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoH8ZgGAH487 nTocYJTmYlER5092rwoX4kvJTKjMSizPii0pzUosPMcpwcChJ8O73BsoJFqWmp1akZeYAAw0m LcHBoyTCuwYkzVtckJhbnJkOkTrFqCglzusHkhAASWSU5sG1wYL7EqOslDAvI9AhQjwFqUW5m SWo8q8YxTkYlYR5J4BM4cnMK4Gb/gpoMRPQYtbYcpDFJYkIKakGxpafy+L/M34/8UxTIXVnQe k2DZ4jt5q/pIZd27RpI+fzXVNryl/E7GEXesvJfCpg8cGCO22FJ436KnJnm81J2G5XMn1moVu e/YG/X1XYskTbbDWOhrBIz0meX7DrvsaP5R8TdoruzmD73bSsx3+3YHnVpGcCPreLPco38Wgt W3ihO2VnHv8mdyWW4oxEQy3mouJEAFxbmQFpAgAA X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-13.tower-21.messagelabs.com!1467632789!22291650!1 X-Originating-IP: [131.159.0.8] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24830 invoked from network); 4 Jul 2016 11:46:29 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 4 Jul 2016 11:46:29 -0000 Received: from files.sec.in.tum.de (files.sec.in.tum.de [131.159.50.1]) by services.sec.in.tum.de (Postfix) with ESMTP id C5BE0100D1FAF; Mon, 4 Jul 2016 13:46:28 +0200 (CEST) Received: from ker.sec.in.tum.de (ker.sec.in.tum.de [131.159.50.36]) by files.sec.in.tum.de (Postfix) with ESMTP id B8F592EEF; Mon, 4 Jul 2016 13:46:28 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Mon, 4 Jul 2016 13:45:42 +0200 Message-Id: <20160704114605.10086-14-proskurin@sec.in.tum.de> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20160704114605.10086-1-proskurin@sec.in.tum.de> References: <20160704114605.10086-1-proskurin@sec.in.tum.de> X-Mailman-Approved-At: Mon, 04 Jul 2016 11:47:11 +0000 Cc: Sergej Proskurin , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH 13/18] arm/altp2m: Make get_page_from_gva ready for altp2m. 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 This commit adapts get_page_from_gva to consider the currently mapped altp2m view during address translation. We also adapt the function's prototype (provide "struct vcpu *" instead of "struct domain *"). This change is required, as the function indirectly calls the function gva_to_ma_par, which requires the mmu to use the current p2m mapping. So if the caller is interested in a page that must be claimed from a vCPU other than current, it must temporarily set the altp2m view that is used by the vCPU in question. Therefore, we need to provide the particular vCPU to this function. Signed-off-by: Sergej Proskurin --- Cc: Stefano Stabellini Cc: Julien Grall --- xen/arch/arm/guestcopy.c | 6 +++--- xen/arch/arm/p2m.c | 19 +++++++++++++------ xen/arch/arm/traps.c | 2 +- xen/include/asm-arm/mm.h | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index ce1c3c3..413125f 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -17,7 +17,7 @@ static unsigned long raw_copy_to_guest_helper(void *to, const void *from, unsigned size = min(len, (unsigned)PAGE_SIZE - offset); struct page_info *page; - page = get_page_from_gva(current->domain, (vaddr_t) to, GV2M_WRITE); + page = get_page_from_gva(current, (vaddr_t) to, GV2M_WRITE); if ( page == NULL ) return len; @@ -64,7 +64,7 @@ unsigned long raw_clear_guest(void *to, unsigned len) unsigned size = min(len, (unsigned)PAGE_SIZE - offset); struct page_info *page; - page = get_page_from_gva(current->domain, (vaddr_t) to, GV2M_WRITE); + page = get_page_from_gva(current, (vaddr_t) to, GV2M_WRITE); if ( page == NULL ) return len; @@ -96,7 +96,7 @@ unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned le unsigned size = min(len, (unsigned)(PAGE_SIZE - offset)); struct page_info *page; - page = get_page_from_gva(current->domain, (vaddr_t) from, GV2M_READ); + page = get_page_from_gva(current, (vaddr_t) from, GV2M_READ); if ( page == NULL ) return len; diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 9c8fefd..23b482f 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1829,10 +1829,11 @@ err: return page; } -struct page_info *get_page_from_gva(struct domain *d, vaddr_t va, +struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, unsigned long flags) { - struct p2m_domain *p2m = &d->arch.p2m; + struct domain *d = v->domain; + struct p2m_domain *p2m = altp2m_active(d) ? p2m_get_altp2m(v) : p2m_get_hostp2m(d); struct page_info *page = NULL; paddr_t maddr = 0; int rc; @@ -1844,17 +1845,23 @@ struct page_info *get_page_from_gva(struct domain *d, vaddr_t va, unsigned long irq_flags; local_irq_save(irq_flags); - p2m_load_VTTBR(d); + + if ( altp2m_active(d) ) + p2m_load_altp2m_VTTBR(v); + else + p2m_load_VTTBR(d); rc = gvirt_to_maddr(va, &maddr, flags); - p2m_load_VTTBR(current->domain); + if ( altp2m_active(current->domain) ) + p2m_load_altp2m_VTTBR(current); + else + p2m_load_VTTBR(current->domain); + local_irq_restore(irq_flags); } else - { rc = gvirt_to_maddr(va, &maddr, flags); - } if ( rc ) goto err; diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 44926ca..6995971 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -957,7 +957,7 @@ static void show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs) return; } - page = get_page_from_gva(v->domain, sp, GV2M_READ); + page = get_page_from_gva(v, sp, GV2M_READ); if ( page == NULL ) { printk("Failed to convert stack to physical address\n"); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 68cf203..19eadd2 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -281,7 +281,7 @@ static inline void *page_to_virt(const struct page_info *pg) return mfn_to_virt(page_to_mfn(pg)); } -struct page_info *get_page_from_gva(struct domain *d, vaddr_t va, +struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, unsigned long flags); /*