From patchwork Wed Oct 18 08:27:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 10014091 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 EECA160215 for ; Wed, 18 Oct 2017 08:30:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD01228AAE for ; Wed, 18 Oct 2017 08:30:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1C5F28AFC; Wed, 18 Oct 2017 08:30:24 +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 46F8328AAE for ; Wed, 18 Oct 2017 08:30:24 +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 1e4jiH-0002j2-G5; Wed, 18 Oct 2017 08:28:29 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4jiG-0002hh-A4 for xen-devel@lists.xen.org; Wed, 18 Oct 2017 08:28:28 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id E6/3C-23269-BA017E95; Wed, 18 Oct 2017 08:28:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHRDpO5qgee RBvcXsFos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkHls5iKtisVtHYfZitgbFdvouRk0NCwF/i ytNbbCA2m4CexMbZr5hAbBEBWYnVXXPYuxi5OJgFjjBKTF11hB0kISwQKPF9ZjsjiM0ioCox/ cxKsGZeARuJS71vWCGGykvsarsIZnMK2EpcP70GrEYIqOb3m6usELaqxOsXu1ggegUlTs58Am YzC0hIHHzxgnkCI+8sJKlZSFILGJlWMWoUpxaVpRbpGlroJRVlpmeU5CZm5ugaGpjq5aYWFye mp+YkJhXrJefnbmIEhg8DEOxgbNrueYhRkoNJSZRX98CzSCG+pPyUyozE4oz4otKc1OJDjDIc HEoSvA/4n0cKCRalpqdWpGXmAAMZJi3BwaMkwhsIkuYtLkjMLc5Mh0idYtTl6Lh59w+TEEtef l6qlDhvBUiRAEhRRmke3AhYVF1ilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMG8DyBSezLwSuE 2vgI5gAjpindMTkCNKEhFSUg2MwSrLVxfmRR01DP4580gly4svnW5MAqkby5bpdNm//jm98gq z6rkaVS2h1nWnUv8aqe3PcizbcuT59eQN9crTMjP1t132OXop0+WF265p208WbBJbz6ygZ/32 8NRLOX+LC7yebudObX+4Std3SkLlczPZ/q1+N/w7p5XGCmlu/jhxTaX5s2IPJZbijERDLeai4 kQA9XTWiqUCAAA= X-Env-Sender: prvs=457a530fd=sergey.dyasli@citrix.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1508315305!79046450!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52684 invoked from network); 18 Oct 2017 08:28:26 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 18 Oct 2017 08:28:26 -0000 X-IronPort-AV: E=Sophos;i="5.43,395,1503360000"; d="scan'208";a="446828219" From: Sergey Dyasli To: Date: Wed, 18 Oct 2017 09:27:20 +0100 Message-ID: <20171018082722.6279-6-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171018082722.6279-1-sergey.dyasli@citrix.com> References: <20171018082722.6279-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Kevin Tian , Jan Beulich , Jun Nakajima , Sergey Dyasli Subject: [Xen-devel] [PATCH v4 5/7] x86/cpuid: update signature of hvm_cr4_guest_valid_bits() 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 With the new cpuid infrastructure there is a domain-wide struct cpuid policy and there is no need to pass a separate struct vcpu * into hvm_cr4_guest_valid_bits() anymore. Make the function accept struct domain * instead and update callers. Signed-off-by: Sergey Dyasli --- xen/arch/x86/hvm/domain.c | 3 ++- xen/arch/x86/hvm/hvm.c | 7 +++---- xen/arch/x86/hvm/svm/svmdebug.c | 4 ++-- xen/arch/x86/hvm/vmx/vvmx.c | 2 +- xen/include/asm-x86/hvm/hvm.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/hvm/domain.c b/xen/arch/x86/hvm/domain.c index 60474649de..ce15ce0470 100644 --- a/xen/arch/x86/hvm/domain.c +++ b/xen/arch/x86/hvm/domain.c @@ -111,6 +111,7 @@ static int check_segment(struct segment_register *reg, enum x86_segment seg) /* Called by VCPUOP_initialise for HVM guests. */ int arch_set_info_hvm_guest(struct vcpu *v, const vcpu_hvm_context_t *ctx) { + const struct domain *d = v->domain; struct cpu_user_regs *uregs = &v->arch.user_regs; struct segment_register cs, ds, ss, es, tr; const char *errstr; @@ -272,7 +273,7 @@ int arch_set_info_hvm_guest(struct vcpu *v, const vcpu_hvm_context_t *ctx) if ( v->arch.hvm_vcpu.guest_efer & EFER_LME ) v->arch.hvm_vcpu.guest_efer |= EFER_LMA; - if ( v->arch.hvm_vcpu.guest_cr[4] & ~hvm_cr4_guest_valid_bits(v, 0) ) + if ( v->arch.hvm_vcpu.guest_cr[4] & ~hvm_cr4_guest_valid_bits(d, false) ) { gprintk(XENLOG_ERR, "Bad CR4 value: %#016lx\n", v->arch.hvm_vcpu.guest_cr[4]); diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 205b4cb685..1784c32c7e 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -928,9 +928,8 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value, X86_CR0_CD | X86_CR0_PG))) /* These bits in CR4 can be set by the guest. */ -unsigned long hvm_cr4_guest_valid_bits(const struct vcpu *v, bool restore) +unsigned long hvm_cr4_guest_valid_bits(const struct domain *d, bool restore) { - const struct domain *d = v->domain; const struct cpuid_policy *p; bool mce, vmxe; @@ -997,7 +996,7 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) return -EINVAL; } - if ( ctxt.cr4 & ~hvm_cr4_guest_valid_bits(v, 1) ) + if ( ctxt.cr4 & ~hvm_cr4_guest_valid_bits(d, true) ) { printk(XENLOG_G_ERR "HVM%d restore: bad CR4 %#" PRIx64 "\n", d->domain_id, ctxt.cr4); @@ -2308,7 +2307,7 @@ int hvm_set_cr4(unsigned long value, bool_t may_defer) struct vcpu *v = current; unsigned long old_cr; - if ( value & ~hvm_cr4_guest_valid_bits(v, 0) ) + if ( value & ~hvm_cr4_guest_valid_bits(v->domain, false) ) { HVM_DBG_LOG(DBG_LEVEL_1, "Guest attempts to set reserved bit in CR4: %lx", diff --git a/xen/arch/x86/hvm/svm/svmdebug.c b/xen/arch/x86/hvm/svm/svmdebug.c index 89ef2db932..e25e3e0423 100644 --- a/xen/arch/x86/hvm/svm/svmdebug.c +++ b/xen/arch/x86/hvm/svm/svmdebug.c @@ -119,9 +119,9 @@ bool svm_vmcb_isvalid(const char *from, const struct vmcb_struct *vmcb, (cr3 >> v->domain->arch.cpuid->extd.maxphysaddr))) ) PRINTF("CR3: MBZ bits are set (%#"PRIx64")\n", cr3); - if ( cr4 & ~hvm_cr4_guest_valid_bits(v, false) ) + if ( cr4 & ~hvm_cr4_guest_valid_bits(v->domain, false) ) PRINTF("CR4: invalid bits are set (%#"PRIx64", valid: %#"PRIx64")\n", - cr4, hvm_cr4_guest_valid_bits(v, false)); + cr4, hvm_cr4_guest_valid_bits(v->domain, false)); if ( vmcb_get_dr6(vmcb) >> 32 ) PRINTF("DR6: bits [63:32] are not zero (%#"PRIx64")\n", diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index dde02c076b..4d9ffc490c 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -2136,7 +2136,7 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content) data = X86_CR4_VMXE; break; case MSR_IA32_VMX_CR4_FIXED1: - data = hvm_cr4_guest_valid_bits(v, 0); + data = hvm_cr4_guest_valid_bits(d, false); break; case MSR_IA32_VMX_MISC: /* Do not support CR3-target feature now */ diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index b687e03dce..47a5f7916d 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -612,7 +612,7 @@ static inline bool altp2m_vcpu_emulate_ve(struct vcpu *v) /* Check CR4/EFER values */ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value, signed int cr0_pg); -unsigned long hvm_cr4_guest_valid_bits(const struct vcpu *v, bool restore); +unsigned long hvm_cr4_guest_valid_bits(const struct domain *d, bool restore); /* * This must be defined as a macro instead of an inline function,