From patchwork Thu Oct 26 17:03:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Euan Harris X-Patchwork-Id: 10028651 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 B252A601E8 for ; Thu, 26 Oct 2017 17:06:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DCAB28E75 for ; Thu, 26 Oct 2017 17:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91F2028E7F; Thu, 26 Oct 2017 17:06:30 +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 52FF528E75 for ; Thu, 26 Oct 2017 17:06:29 +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 1e7lZV-0002eg-T7; Thu, 26 Oct 2017 17:03:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7lZU-0002dQ-Bw for xen-devel@lists.xenproject.org; Thu, 26 Oct 2017 17:03:56 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 4D/BF-21967-C7512F95; Thu, 26 Oct 2017 17:03:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRWlGSWpSXmKPExsXitHSDvW616Kd Ig4P3RCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ownV4+yFbzQrPjU28HcwPhErouRk0NCwF/i z8GlLCA2m4CWxO4PC9m7GDk4RARUJG7vNehi5OJgFuhllFj6/gITSFxYwEdi9udyEJNFQFVi2 qNAkE5eATeJ538bWSEmKkhMefieGcTmFHCXOLRwExuILQRUc/HbL1YIW1niw5U17BC9ghInZz 4Bu4BZQELi4IsXzBMYeWchSc1CklrAyLSKUaM4tagstUjXyEgvqSgzPaMkNzEzR9fQwFQvN7W 4ODE9NScxqVgvOT93EyMwcOoZGBh3MO5p9zvEKMnBpCTKy7DnQ6QQX1J+SmVGYnFGfFFpTmrx IUYZDg4lCd6Fwp8ihQSLUtNTK9Iyc4AhDJOW4OBREuG9BJLmLS5IzC3OTIdInWI05ui4efcPE 8ezma8bmIVY8vLzUqXEeU1FgEoFQEozSvPgBsFi6xKjrJQwLyMDA4MQT0FqUW5mCar8K0ZxDk YlYYiFPJl5JXD7XgGdwgR0SpPqB5BTShIRUlINjI3Z6tqPW2MWMkYUeO2tXP/Gm1HoYADP5yh +R+N9kjGTxHMNOdJmGbyUn3l/vuDvbyfu9iqa31r355/lNY4ZTTlObK8m7/Putjt3f1+BWG2S 3txJnWzir7Y+/bT98WTbH6WaLPeFth06J6ko8sCia3FOurX4HLG3Ky7+a+vfF7bHY+0ZJeZfv 5VYijMSDbWYi4oTAaAS1ZioAgAA X-Env-Sender: prvs=465eced58=euan.harris@citrix.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1509037429!105948291!4 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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41357 invoked from network); 26 Oct 2017 17:03:55 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 26 Oct 2017 17:03:55 -0000 X-IronPort-AV: E=Sophos;i="5.44,301,1505779200"; d="scan'208";a="456259612" From: Euan Harris To: Date: Thu, 26 Oct 2017 18:03:16 +0100 Message-ID: <1509037399-48926-7-git-send-email-euan.harris@citrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1509037399-48926-1-git-send-email-euan.harris@citrix.com> References: <1509037399-48926-1-git-send-email-euan.harris@citrix.com> MIME-Version: 1.0 Cc: andrew.cooper3@citrix.com, kevin.tian@intel.com, Euan Harris , jun.nakajima@intel.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH 6/9] x86/vvmx: Remove operand reading from decode_vmx_inst() 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 Use operand_read() to read memory operands instead of using the value read by decode_vmx_inst() in the following functions: * nvmx_handle_invept() * nvmx_handle_invvpid() * nvmx_handle_vmclear() * nvmx_handle_vmptrld() * nvmx_handle_vmxon() * nvmx_handle_vmwrite() Signed-off-by: Euan Harris --- xen/arch/x86/hvm/vmx/vvmx.c | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index 7cda37b136..fc2123c7c0 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -456,7 +456,7 @@ gp_fault: static int decode_vmx_inst(struct cpu_user_regs *regs, struct vmx_inst_decoded *decode, - unsigned long *poperandS, int vmxon_check) + int vmxon_check) { struct vcpu *v = current; union vmx_inst_info info; @@ -473,13 +473,6 @@ static int decode_vmx_inst(struct cpu_user_regs *regs, if ( info.fields.memreg ) { decode->op[0].type = VMX_INST_MEMREG_TYPE_REG; decode->op[0].reg_idx = info.fields.reg1; - if ( poperandS != NULL ) - { - int rc = operand_read(poperandS, &decode->op[0], regs, - decode->op[0].len); - if ( rc != X86EMUL_OKAY ) - return rc; - } } else { @@ -516,14 +509,6 @@ static int decode_vmx_inst(struct cpu_user_regs *regs, decode->op[0].mem = base; decode->op[0].len = size; - - if ( poperandS != NULL ) - { - int rc = operand_read(poperandS, &decode->op[0], regs, - decode->op[0].len); - if ( rc != X86EMUL_OKAY ) - return rc; - } } decode->op[1].type = VMX_INST_MEMREG_TYPE_REG; @@ -1513,7 +1498,11 @@ int nvmx_handle_vmxon(struct cpu_user_regs *regs) uint32_t nvmcs_revid; int rc; - rc = decode_vmx_inst(regs, &decode, &gpa, 1); + rc = decode_vmx_inst(regs, &decode, 1); + if ( rc != X86EMUL_OKAY ) + return rc; + + rc = operand_read(&gpa, &decode.op[0], regs, decode.op[0].len); if ( rc != X86EMUL_OKAY ) return rc; @@ -1729,7 +1718,11 @@ int nvmx_handle_vmptrld(struct cpu_user_regs *regs) unsigned long gpa = 0; int rc; - rc = decode_vmx_inst(regs, &decode, &gpa, 0); + rc = decode_vmx_inst(regs, &decode, 0); + if ( rc != X86EMUL_OKAY ) + return rc; + + rc = operand_read(&gpa, &decode.op[0], regs, decode.op[0].len); if ( rc != X86EMUL_OKAY ) return rc; @@ -1801,7 +1794,7 @@ int nvmx_handle_vmptrst(struct cpu_user_regs *regs) unsigned long gpa = 0; int rc; - rc = decode_vmx_inst(regs, &decode, NULL, 0); + rc = decode_vmx_inst(regs, &decode, 0); if ( rc != X86EMUL_OKAY ) return rc; @@ -1828,7 +1821,11 @@ int nvmx_handle_vmclear(struct cpu_user_regs *regs) void *vvmcs; int rc; - rc = decode_vmx_inst(regs, &decode, &gpa, 0); + rc = decode_vmx_inst(regs, &decode, 0); + if ( rc != X86EMUL_OKAY ) + return rc; + + rc = operand_read(&gpa, &decode.op[0], regs, decode.op[0].len); if ( rc != X86EMUL_OKAY ) return rc; @@ -1879,7 +1876,7 @@ int nvmx_handle_vmread(struct cpu_user_regs *regs) int rc; unsigned long vmcs_encoding = 0; - rc = decode_vmx_inst(regs, &decode, NULL, 0); + rc = decode_vmx_inst(regs, &decode, 0); if ( rc != X86EMUL_OKAY ) return rc; @@ -1928,10 +1925,13 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs) enum vmx_insn_errno err; int rc; - if ( decode_vmx_inst(regs, &decode, &operand, 0) - != X86EMUL_OKAY ) + if ( decode_vmx_inst(regs, &decode, 0) != X86EMUL_OKAY ) return X86EMUL_EXCEPTION; + rc = operand_read(&operand, &decode.op[0], regs, decode.op[0].len); + if ( rc != X86EMUL_OKAY ) + return rc; + if ( vcpu_nestedhvm(v).nv_vvmcxaddr == INVALID_PADDR ) { vmfail_invalid(regs); @@ -1973,11 +1973,10 @@ int nvmx_handle_vmwrite(struct cpu_user_regs *regs) int nvmx_handle_invept(struct cpu_user_regs *regs) { struct vmx_inst_decoded decode; - unsigned long eptp; unsigned long invept_type = 0; int ret; - if ( (ret = decode_vmx_inst(regs, &decode, &eptp, 0)) != X86EMUL_OKAY ) + if ( (ret = decode_vmx_inst(regs, &decode, 0)) != X86EMUL_OKAY ) return ret; ret = operand_read(&invept_type, &decode.op[1], regs, decode.op[1].len); @@ -1988,6 +1987,12 @@ int nvmx_handle_invept(struct cpu_user_regs *regs) { case INVEPT_SINGLE_CONTEXT: { + unsigned long eptp; + + ret = operand_read(&eptp, &decode.op[0], regs, decode.op[0].len); + if ( ret ) + return ret; + np2m_flush_base(current, eptp); break; } @@ -2009,7 +2014,7 @@ int nvmx_handle_invvpid(struct cpu_user_regs *regs) unsigned long invvpid_type = 0; int ret; - if ( (ret = decode_vmx_inst(regs, &decode, NULL, 0)) != X86EMUL_OKAY ) + if ( (ret = decode_vmx_inst(regs, &decode, 0)) != X86EMUL_OKAY ) return ret; ret = operand_read(&invvpid_type, &decode.op[1], regs, decode.op[1].len);