From patchwork Mon Aug 1 17:10:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9254613 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 2A0A36048B for ; Mon, 1 Aug 2016 17:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16BD02843C for ; Mon, 1 Aug 2016 17:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B5DD284AE; Mon, 1 Aug 2016 17:13:57 +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 A180F2843C for ; Mon, 1 Aug 2016 17:13:56 +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 1bUGkU-0006w9-S8; Mon, 01 Aug 2016 17:11:30 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUGkS-0006ri-SD for xen-devel@lists.xenproject.org; Mon, 01 Aug 2016 17:11:28 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id E0/CE-21406-0C28F975; Mon, 01 Aug 2016 17:11:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsXSPJ+BQ3d/0/x wg0f3pCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxl70sKpghX7D3xmrGB8R9fFyMXh5DARkaJ hb/vsnYxcgI5yxklTr+JB7HZBAwkprxeCRYXEVCSuLdqMhNIA7NAE6PEvcYHbCAJYQEnibeNs 8CKWARUJTrvbWHuYuTg4BWwlZjUKw0SlhCQk2g4f58ZxOYECvfdXs4CsctGYvHV/cwTGLkXMD KsYlQvTi0qSy3SNdFLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAj0LQMQ7GDsvux /iFGSg0lJlDehYH64EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQne7Y1AOcGi1PTUirTMHGCQwaQl OHiURHg7QNK8xQWJucWZ6RCpU4yKUuK8aSAJAZBERmkeXBsssC8xykoJ8zICHSLEU5BalJtZg ir/ilGcg1FJmHcdyBSezLwSuOmvgBYzAS1OtJ8DsrgkESEl1cC47OH1tdzWjwSmNqhIzt49t0 RH8sGSj7esl8UGtJg23o66KOjiWVOydt+NvF5WKwVNvWoXhX8TJWZMPD3/q9+9extWXZr+fke 4fXHIis/VdQcWf787l3+9vORaz5r7CwTcXAraHhjx/6jYL5X9R9GpjPnS9R/HJxp/ZBfIrvyg Flte+fiSlnSpEktxRqKhFnNRcSIAG7VCuGcCAAA= X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-8.tower-21.messagelabs.com!1470071487!26557138!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.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52111 invoked from network); 1 Aug 2016 17:11:27 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-8.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Aug 2016 17:11:27 -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 479FA10100E94; Mon, 1 Aug 2016 19:11:11 +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 3B7CE4400; Mon, 1 Aug 2016 19:11:11 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Mon, 1 Aug 2016 19:10:15 +0200 Message-Id: <20160801171028.11615-13-proskurin@sec.in.tum.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160801171028.11615-1-proskurin@sec.in.tum.de> References: <20160801171028.11615-1-proskurin@sec.in.tum.de> Cc: Sergej Proskurin , Julien Grall , Stefano Stabellini Subject: [Xen-devel] [PATCH v2 12/25] arm/altp2m: Add HVMOP_altp2m_switch_p2m. 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 Signed-off-by: Sergej Proskurin --- Cc: Stefano Stabellini Cc: Julien Grall --- xen/arch/arm/altp2m.c | 32 ++++++++++++++++++++++++++++++++ xen/arch/arm/hvm.c | 2 +- xen/include/asm-arm/altp2m.h | 4 ++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c index 80ed553..7404f42 100644 --- a/xen/arch/arm/altp2m.c +++ b/xen/arch/arm/altp2m.c @@ -33,6 +33,38 @@ struct p2m_domain *altp2m_get_altp2m(struct vcpu *v) return v->domain->arch.altp2m_p2m[index]; } +int altp2m_switch_domain_altp2m_by_id(struct domain *d, unsigned int idx) +{ + struct vcpu *v; + int rc = -EINVAL; + + if ( idx >= MAX_ALTP2M ) + return rc; + + domain_pause_except_self(d); + + altp2m_lock(d); + + if ( d->arch.altp2m_vttbr[idx] != INVALID_VTTBR ) + { + for_each_vcpu( d, v ) + if ( idx != vcpu_altp2m(v).p2midx ) + { + atomic_dec(&altp2m_get_altp2m(v)->active_vcpus); + vcpu_altp2m(v).p2midx = idx; + atomic_inc(&altp2m_get_altp2m(v)->active_vcpus); + } + + rc = 0; + } + + altp2m_unlock(d); + + domain_unpause_except_self(d); + + return rc; +} + static void altp2m_vcpu_reset(struct vcpu *v) { struct altp2mvcpu *av = &vcpu_altp2m(v); diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index df29cdc..3b508df 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -129,7 +129,7 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg) break; case HVMOP_altp2m_switch_p2m: - rc = -EOPNOTSUPP; + rc = altp2m_switch_domain_altp2m_by_id(d, a.u.view.view); break; case HVMOP_altp2m_set_mem_access: diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h index afa1580..790bb33 100644 --- a/xen/include/asm-arm/altp2m.h +++ b/xen/include/asm-arm/altp2m.h @@ -49,6 +49,10 @@ void altp2m_teardown(struct domain *d); void altp2m_vcpu_initialise(struct vcpu *v); void altp2m_vcpu_destroy(struct vcpu *v); +/* Switch alternate p2m for entire domain */ +int altp2m_switch_domain_altp2m_by_id(struct domain *d, + unsigned int idx); + /* Make a specific alternate p2m valid. */ int altp2m_init_by_id(struct domain *d, unsigned int idx);