From patchwork Mon Aug 1 17:10:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9254615 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 75E2F6089F for ; Mon, 1 Aug 2016 17:13:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 628FB2843C for ; Mon, 1 Aug 2016 17:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 572BC284AE; Mon, 1 Aug 2016 17:13:58 +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 2D9202843C for ; Mon, 1 Aug 2016 17:13:57 +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 1bUGkE-0006No-Cb; Mon, 01 Aug 2016 17:11:14 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUGkD-0006LW-5t for xen-devel@lists.xenproject.org; Mon, 01 Aug 2016 17:11:13 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id E6/D1-16889-0B28F975; Mon, 01 Aug 2016 17:11:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsXSPJ+BQ3d90/x wg+WTTS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owjn7+wFxxUqLhx9z9zA+NMyS5GLg4hgY2M Euf/3GeDcFYwSnw42ATkcHKwCRhITHm9khXEFhFQkri3ajITSBGzQBOjxL3GB2BFwgLOErvuP mIEsVkEVCW+3n8MZvMK2EicvHUDzJYQkJNoOH+fGcTmFLCV6Lu9nAXEFgKqWXx1P/MERu4FjA yrGNWLU4vKUot0zfWSijLTM0pyEzNzdA0NTfRyU4uLE9NTcxKTivWS83M3MQI9zAAEOxi/LHE +xCjJwaQkyptQMD9ciC8pP6UyI7E4I76oNCe1+BCjDAeHkgTv9kagnGBRanpqRVpmDjDUYNIS HDxKIrz/QdK8xQWJucWZ6RCpU4yKUuK8F0ESAiCJjNI8uDZYeF9ilJUS5mUEOkSIpyC1KDezB FX+FaM4B6OSMO86kCk8mXklcNNfAS1mAlqcaD8HZHFJIkJKqoExPsPq/p+iqPrHnOUl+idb9j zbwOMmsCmr+IH+DbEjvUtsy3hXc6/Zl/r+bOiGs0vmaTaf/bd+zYa787jnSci8XSbuq/v/+4Z TtQ/kGEVOT/hpdcd6cr3DfhO5/k291bPerTxbs29p/2mJ4I/mbH7PW1sj1aWm6v1803gyddnz s8wfY9/6MAfPVmIpzkg01GIuKk4EAH9VbuxqAgAA X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-10.tower-27.messagelabs.com!1470071471!57209545!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 14739 invoked from network); 1 Aug 2016 17:11:11 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-10.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Aug 2016 17:11:11 -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 C30B510100E94; Mon, 1 Aug 2016 19:11:10 +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 B61E2F100A; Mon, 1 Aug 2016 19:11:10 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Mon, 1 Aug 2016 19:10:04 +0200 Message-Id: <20160801171028.11615-2-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 01/25] arm/altp2m: Add first altp2m HVMOP stubs. 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 moves the altp2m-related code from x86 to ARM. Functions that are no yet supported notify the caller or print a BUG message stating their absence. Also, the struct arch_domain is extended with the altp2m_active attribute, representing the current altp2m activity configuration of the domain. Signed-off-by: Sergej Proskurin --- Cc: Stefano Stabellini Cc: Julien Grall --- v2: Removed altp2m command-line option: Guard through HVM_PARAM_ALTP2M. Removed not used altp2m helper stubs in altp2m.h. --- xen/arch/arm/hvm.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/altp2m.h | 4 +-- xen/include/asm-arm/domain.h | 3 ++ 3 files changed, 84 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index d999bde..eb524ae 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -32,6 +32,81 @@ #include +#include + +static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg) +{ + struct xen_hvm_altp2m_op a; + struct domain *d = NULL; + int rc = 0; + + if ( copy_from_guest(&a, arg, 1) ) + return -EFAULT; + + if ( a.pad1 || a.pad2 || + (a.version != HVMOP_ALTP2M_INTERFACE_VERSION) || + (a.cmd < HVMOP_altp2m_get_domain_state) || + (a.cmd > HVMOP_altp2m_change_gfn) ) + return -EINVAL; + + d = (a.cmd != HVMOP_altp2m_vcpu_enable_notify) ? + rcu_lock_domain_by_any_id(a.domain) : rcu_lock_current_domain(); + + if ( d == NULL ) + return -ESRCH; + + if ( (a.cmd != HVMOP_altp2m_get_domain_state) && + (a.cmd != HVMOP_altp2m_set_domain_state) && + !d->arch.altp2m_active ) + { + rc = -EOPNOTSUPP; + goto out; + } + + if ( (rc = xsm_hvm_altp2mhvm_op(XSM_TARGET, d)) ) + goto out; + + switch ( a.cmd ) + { + case HVMOP_altp2m_get_domain_state: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_set_domain_state: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_vcpu_enable_notify: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_create_p2m: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_destroy_p2m: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_switch_p2m: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_set_mem_access: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_change_gfn: + rc = -EOPNOTSUPP; + break; + } + +out: + rcu_unlock_domain(d); + + return rc; +} + long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc = 0; @@ -80,6 +155,10 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) rc = -EINVAL; break; + case HVMOP_altp2m: + rc = do_altp2m_op(arg); + break; + default: { gdprintk(XENLOG_DEBUG, "HVMOP op=%lu: not implemented\n", op); diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h index a87747a..0711796 100644 --- a/xen/include/asm-arm/altp2m.h +++ b/xen/include/asm-arm/altp2m.h @@ -2,6 +2,7 @@ * Alternate p2m * * Copyright (c) 2014, Intel Corporation. + * Copyright (c) 2016, Sergej Proskurin . * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -24,8 +25,7 @@ /* Alternate p2m on/off per domain */ static inline bool_t altp2m_active(const struct domain *d) { - /* Not implemented on ARM. */ - return 0; + return d->arch.altp2m_active; } /* Alternate p2m VCPU */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 9452fcd..cc4bda0 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -126,6 +126,9 @@ struct arch_domain paddr_t efi_acpi_gpa; paddr_t efi_acpi_len; #endif + + /* altp2m: allow multiple copies of host p2m */ + bool_t altp2m_active; } __cacheline_aligned; struct arch_vcpu