From patchwork Mon Mar 13 10:51:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 9620463 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 A159760522 for ; Mon, 13 Mar 2017 10:54:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 945C328458 for ; Mon, 13 Mar 2017 10:54:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 895372845C; Mon, 13 Mar 2017 10:54:03 +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 3EA0728459 for ; Mon, 13 Mar 2017 10:54:03 +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 1cnNa2-0007Pb-4A; Mon, 13 Mar 2017 10:51:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnNa0-0007Or-Mq for xen-devel@lists.xen.org; Mon, 13 Mar 2017 10:51:56 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 4D/31-29481-CC976C85; Mon, 13 Mar 2017 10:51:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42JxWrohUvd05bE Ig8M9yhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bipk1MBUdEKk4v+MbYwDhRoIuRk0NCwF/i zbzFbCA2m4CexMbZr5hAbBEBWYnVXXPYuxi5OJgFjjBKTF11hB0kISzgJvHiwxFWEJtFQFVi6 8oDYHFeAVuJ9bcns0EMlZO4tO0LcxcjBwengJ3E+QP8IGEhoJKnl+4zQtiqEq9f7GKBaBWUOD nzCZjNLCAhcfDFC+YJjLyzkKRmIUktYGRaxahenFpUllqka66XVJSZnlGSm5iZo2toYKqXm1p cnJiempOYVKyXnJ+7iREYOgxAsIPx2GTnQ4ySHExKorwxlscihPiS8lMqMxKLM+KLSnNSiw8x ynBwKEnwMgNDUUiwKDU9tSItMwcYxDBpCQ4eJRHexRVAad7igsTc4sx0iNQpRkUpcd7bIAkBk ERGaR5cGyxyLjHKSgnzMgIdIsRTkFqUm1mCKv+KUZyDUUmY9yHIFJ7MvBK46a+AFjMBLU78eQ RkcUkiQkqqgdGx9/mylP++Ux9eTFu+WML+yLKXm7bm+uWdF1z5e9ZvtZm/JAT1zEp4pyrya1x eqei7aoJed+QkF+VPOtPy286/dVowU/JFoX8s192zktFxCqK5f5oiz+V5q1tpRL1bvY95IrfV pbM79J/Ws0o3zr65xmTL/BlfWGbpMtSGOJo8XfcrRijSvUmJpTgj0VCLuag4EQDzTrp/lwIAA A== X-Env-Sender: prvs=23829f5b7=sergey.dyasli@citrix.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1489402313!86280346!2 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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50455 invoked from network); 13 Mar 2017 10:51:55 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 13 Mar 2017 10:51:55 -0000 X-IronPort-AV: E=Sophos;i="5.36,158,1486425600"; d="scan'208";a="413355203" From: Sergey Dyasli To: Date: Mon, 13 Mar 2017 10:51:41 +0000 Message-ID: <20170313105143.20842-2-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170313105143.20842-1-sergey.dyasli@citrix.com> References: <20170313105143.20842-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 1/3] x86/vvmx: add mov-ss blocking check to vmentry 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 Intel SDM states that if there is a current VMCS and there is MOV-SS blocking, VMFailValid occurs and control passes to the next instruction. Implement such behaviour for nested vmlaunch and vmresume. Signed-off-by: Sergey Dyasli Acked-by: Kevin Tian --- xen/arch/x86/hvm/vmx/vvmx.c | 16 ++++++++++++++++ xen/include/asm-x86/hvm/vmx/vmcs.h | 1 + 2 files changed, 17 insertions(+) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index e2c0951..09e4250 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1572,6 +1572,7 @@ int nvmx_handle_vmresume(struct cpu_user_regs *regs) bool_t launched; struct vcpu *v = current; struct nestedvmx *nvmx = &vcpu_2_nvmx(v); + unsigned long intr_shadow; int rc = vmx_inst_check_privilege(regs, 0); if ( rc != X86EMUL_OKAY ) @@ -1583,6 +1584,13 @@ int nvmx_handle_vmresume(struct cpu_user_regs *regs) return X86EMUL_OKAY; } + __vmread(GUEST_INTERRUPTIBILITY_INFO, &intr_shadow); + if ( intr_shadow & VMX_INTR_SHADOW_MOV_SS ) + { + vmfail_valid(regs, VMX_INSN_VMENTRY_BLOCKED_BY_MOV_SS); + return X86EMUL_OKAY; + } + launched = vvmcs_launched(&nvmx->launched_list, PFN_DOWN(v->arch.hvm_vmx.vmcs_shadow_maddr)); if ( !launched ) @@ -1598,6 +1606,7 @@ int nvmx_handle_vmlaunch(struct cpu_user_regs *regs) bool_t launched; struct vcpu *v = current; struct nestedvmx *nvmx = &vcpu_2_nvmx(v); + unsigned long intr_shadow; int rc = vmx_inst_check_privilege(regs, 0); if ( rc != X86EMUL_OKAY ) @@ -1609,6 +1618,13 @@ int nvmx_handle_vmlaunch(struct cpu_user_regs *regs) return X86EMUL_OKAY; } + __vmread(GUEST_INTERRUPTIBILITY_INFO, &intr_shadow); + if ( intr_shadow & VMX_INTR_SHADOW_MOV_SS ) + { + vmfail_valid(regs, VMX_INSN_VMENTRY_BLOCKED_BY_MOV_SS); + return X86EMUL_OKAY; + } + launched = vvmcs_launched(&nvmx->launched_list, PFN_DOWN(v->arch.hvm_vmx.vmcs_shadow_maddr)); if ( launched ) diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h index f465fff..dc5d91f 100644 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h @@ -515,6 +515,7 @@ enum vmx_insn_errno VMX_INSN_VMPTRLD_INCORRECT_VMCS_ID = 11, VMX_INSN_UNSUPPORTED_VMCS_COMPONENT = 12, VMX_INSN_VMXON_IN_VMX_ROOT = 15, + VMX_INSN_VMENTRY_BLOCKED_BY_MOV_SS = 26, VMX_INSN_FAIL_INVALID = ~0, };