From patchwork Mon Jul 4 11:45:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergej Proskurin X-Patchwork-Id: 9212347 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 9DE1E60572 for ; Mon, 4 Jul 2016 11:48:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F355286DE for ; Mon, 4 Jul 2016 11:48:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83A1B286E2; Mon, 4 Jul 2016 11:48:41 +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 17040286DE for ; Mon, 4 Jul 2016 11:48:41 +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 1bK2LM-0008RN-Ue; Mon, 04 Jul 2016 11:47:16 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bK2Kk-000848-Fc for xen-devel@lists.xenproject.org; Mon, 04 Jul 2016 11:46:38 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id EB/D4-07949-D9C4A775; Mon, 04 Jul 2016 11:46:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsXSPJ+BQ3euT1W 4wd6Nghbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8af09NZCo6rVtyZW9PAOEO2i5GLQ0hgI6PE zh3rWSCc5YwSXae3MHYxcnKwCRhITHm9khXEFhFQkri3ajITSBGzQBOjxL3GB2wgCWEBB4nTO xeA2SwCqhLv5p8Ba+YVsJVYf24hE4gtISAnMXnxJbA4J1C8oeMTWFxIwEai++5jtgmM3AsYGV YxahSnFpWlFukaWuglFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgR6uJ6BgXEH4+/ TnocYJTmYlER5092rwoX4kvJTKjMSizPii0pzUosPMcpwcChJ8LJ5A+UEi1LTUyvSMnOAoQaT luDgURLh3ekFlOYtLkjMLc5Mh0idYlSUEud9ApIQAElklObBtcHC+xKjrJQwLyMDA4MQT0FqU W5mCar8K0ZxDkYlYd4wkO08mXklcNNfAS1mAlrMGlsOsrgkESEl1cBYePrEz09rfOqKZ/Tb/j DsZr8klJD+9tP3H86zz3FYlSsu/3F/7QTVLTb2cxaLJa6ufn52LwvXga7Zq3UNmZy42ZWuPeg QWfG0vvPg7z1hBy8HMa+YNXNp8eQzcy3N7uhUyVybXPp79vYXd7zdNTViQ1WYEyu9FBh/r1q/ JpLFTTlsiXbzmqn5SizFGYmGWsxFxYkAheuAZWoCAAA= X-Env-Sender: proskurin@sec.in.tum.de X-Msg-Ref: server-2.tower-31.messagelabs.com!1467632797!48702584!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 48669 invoked from network); 4 Jul 2016 11:46:37 -0000 Received: from mail-out1.informatik.tu-muenchen.de (HELO mail-out1.informatik.tu-muenchen.de) (131.159.0.8) by server-2.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 4 Jul 2016 11:46:37 -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 E116E100D1FAF; Mon, 4 Jul 2016 13:46:36 +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 D45E52EEF; Mon, 4 Jul 2016 13:46:36 +0200 (CEST) From: Sergej Proskurin To: xen-devel@lists.xenproject.org Date: Mon, 4 Jul 2016 13:45:49 +0200 Message-Id: <20160704114605.10086-21-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 02/18] 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, represeting the current altp2m activity configuration of the domain. Signed-off-by: Sergej Proskurin --- Cc: Stefano Stabellini Cc: Julien Grall --- xen/arch/arm/hvm.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/altp2m.h | 22 ++++++++++-- xen/include/asm-arm/domain.h | 3 ++ 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index 3615036..1118f22 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -32,6 +32,7 @@ #include +#include #include /* Xen command-line option enabling altp2m */ @@ -54,6 +55,83 @@ static int __init hvm_enable(void) } presmp_initcall(hvm_enable); +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 ( !hvm_altp2m_supported() ) + return -EOPNOTSUPP; + + 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; @@ -102,6 +180,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..16ae9d6 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 */ @@ -36,4 +36,22 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) return 0; } +static inline void altp2m_vcpu_initialise(struct vcpu *v) +{ + /* Not implemented on ARM, should not be reached. */ + BUG(); +} + +static inline void altp2m_vcpu_destroy(struct vcpu *v) +{ + /* Not implemented on ARM, should not be reached. */ + BUG(); +} + +static inline void altp2m_vcpu_reset(struct vcpu *v) +{ + /* Not implemented on ARM, should not be reached. */ + BUG(); +} + #endif /* __ASM_ARM_ALTP2M_H */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 979f7de..2039f16 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -127,6 +127,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