From patchwork Mon Jun 26 10:44:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 9809107 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 A5DB960209 for ; Mon, 26 Jun 2017 10:47:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB02126D08 for ; Mon, 26 Jun 2017 10:47:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D6192837E; Mon, 26 Jun 2017 10:47:14 +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 5E4CE26D08 for ; Mon, 26 Jun 2017 10:47:13 +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 1dPRVb-00029n-DE; Mon, 26 Jun 2017 10:44:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPRVZ-00028W-PV for xen-devel@lists.xen.org; Mon, 26 Jun 2017 10:44:41 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 08/A7-03557-995E0595; Mon, 26 Jun 2017 10:44:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHSDve6MpwG RBlOf61gs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmPttxmL3gvU7FvURNzA+Ni8S5GTg4JAX+J 4x/+s4HYbAJ6Ehtnv2ICsUUEZCVWd81h72Lk4mAWOMIoMXXVESCHg0NYwFpi/V8vkBoWAVWJh gsfWEBsXgFbib8rtjBBzJSX2NV2kRXE5hSwk5i74DRYjRBQTdPTRWwQtqrE6xe7oHoFJU7OfA JmMwtISBx88YJ5AiPvLCSpWUhSCxiZVjGqF6cWlaUW6VroJRVlpmeU5CZm5ugaGpjp5aYWFye mp+YkJhXrJefnbmIEhg4DEOxgnH3Z/xCjJAeTkigvx5OASCG+pPyUyozE4oz4otKc1OJDjBoc HAJXzs2dziTFkpefl6okwasJUidYlJqeWpGWmQMMbphSCQ4eJRHeow+B0rzFBYm5xZnpEKlTj IpS4rwuIH0CIImM0jy4NlhEXWKUlRLmZQQ6SoinILUoN7MEVf4VozgHo5Iwby7IFJ7MvBK46a +AFjMBLWaZB7a4JBEhJdXAuCNsb7Dw8YDz7Xonwlq1uCv283B5zWSWPfbv+yfX1vsRO38q6wU 9DAkvzl90mr9IssfOJs92l4v8xD0bGRIkwj3MFT5l7jiwfV2koHHFLYPDLNHH9jz1NnzsVqe9 TFXH8V3Gdb7auB8nFcvt3Tk4Lvycfjm64qHOBqeF+VdrmPP6+xhXPH2mxFKckWioxVxUnAgA2 6rqt6MCAAA= X-Env-Sender: prvs=343936acc=sergey.dyasli@citrix.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1498473878!75551093!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60094 invoked from network); 26 Jun 2017 10:44:40 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 26 Jun 2017 10:44:40 -0000 X-IronPort-AV: E=Sophos;i="5.39,395,1493683200"; d="scan'208";a="437812350" From: Sergey Dyasli To: Date: Mon, 26 Jun 2017 11:44:34 +0100 Message-ID: <20170626104435.25508-6-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170626104435.25508-1-sergey.dyasli@citrix.com> References: <20170626104435.25508-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Kevin Tian , Jan Beulich , Jun Nakajima , Sergey Dyasli Subject: [Xen-devel] [PATCH v1 5/6] vvmx: add per domain vmx msr policy 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Having a policy per domain allows to sensibly query what VMX features the domain has, which unblocks some other nested virt work items. For now, make policy for each domain equal to hvm_max_vmx_msr_policy. In the future it should be possible to independently configure the policy for each domain. Signed-off-by: Sergey Dyasli Reviewed-by: Jan Beulich --- xen/arch/x86/domain.c | 6 ++++++ xen/arch/x86/hvm/vmx/vvmx.c | 14 +++++++++++++- xen/include/asm-x86/domain.h | 2 ++ xen/include/asm-x86/hvm/vmx/vvmx.h | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 49388f48d7..2a3518328e 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -419,6 +419,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, { d->arch.emulation_flags = 0; d->arch.cpuid = ZERO_BLOCK_PTR; /* Catch stray misuses. */ + d->arch.vmx_msr = ZERO_BLOCK_PTR; } else { @@ -464,6 +465,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, if ( (rc = init_domain_cpuid_policy(d)) ) goto fail; + if ( (rc = init_domain_vmx_msr_policy(d)) ) + goto fail; + d->arch.ioport_caps = rangeset_new(d, "I/O Ports", RANGESETF_prettyprint_hex); rc = -ENOMEM; @@ -535,6 +539,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, cleanup_domain_irq_mapping(d); free_xenheap_page(d->shared_info); xfree(d->arch.cpuid); + xfree(d->arch.vmx_msr); if ( paging_initialised ) paging_final_teardown(d); free_perdomain_mappings(d); @@ -549,6 +554,7 @@ void arch_domain_destroy(struct domain *d) xfree(d->arch.e820); xfree(d->arch.cpuid); + xfree(d->arch.vmx_msr); free_domain_pirqs(d); if ( !is_idle_domain(d) ) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index 657371ec69..ae24dc4680 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -2078,6 +2078,18 @@ void __init calculate_hvm_max_policy(void) p->available &= ~0x20000; } +int init_domain_vmx_msr_policy(struct domain *d) +{ + d->arch.vmx_msr = xmalloc(struct vmx_msr_policy); + + if ( !d->arch.vmx_msr ) + return -ENOMEM; + + *d->arch.vmx_msr = hvm_max_vmx_msr_policy; + + return 0; +} + /* * Capability reporting */ @@ -2085,7 +2097,7 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content) { struct vcpu *v = current; struct domain *d = v->domain; - struct vmx_msr_policy *p = &hvm_max_vmx_msr_policy; + struct vmx_msr_policy *p = d->arch.vmx_msr; u64 data; int r = 1; diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 924caac834..3cb753e46b 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -359,6 +359,8 @@ struct arch_domain /* CPUID Policy. */ struct cpuid_policy *cpuid; + struct vmx_msr_policy *vmx_msr; + struct PITState vpit; /* TSC management (emulation, pv, scaling, stats) */ diff --git a/xen/include/asm-x86/hvm/vmx/vvmx.h b/xen/include/asm-x86/hvm/vmx/vvmx.h index ca2fb2535c..627112bea8 100644 --- a/xen/include/asm-x86/hvm/vmx/vvmx.h +++ b/xen/include/asm-x86/hvm/vmx/vvmx.h @@ -246,5 +246,8 @@ int nept_translate_l2ga(struct vcpu *v, paddr_t l2ga, uint64_t *exit_qual, uint32_t *exit_reason); int nvmx_cpu_up_prepare(unsigned int cpu); void nvmx_cpu_dead(unsigned int cpu); + +int init_domain_vmx_msr_policy(struct domain *d); + #endif /* __ASM_X86_HVM_VVMX_H__ */