From 68a15d6bd84ad3e66f997940accaf9485352e604 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 1 Nov 2018 17:37:48 +0000 Subject: [PATCH] x86/vvmx: Fixes to VMWRITE emulation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Don't assume that decode_vmx_inst() always returns X86EMUL_EXCEPTION. * The okay boolean is never written, making the else case dead. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné Reviewed-by: Sergey Dyasli Acked-by: Kevin Tian --- xen/arch/x86/hvm/vmx/vvmx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index 5daab82dc0..41c4e2fb82 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1872,11 +1872,12 @@ static int nvmx_handle_vmwrite(struct cpu_user_regs *regs) struct vmx_inst_decoded decode; unsigned long operand; u64 vmcs_encoding; - bool_t okay = 1; enum vmx_insn_errno err; + int rc; - if ( decode_vmx_inst(regs, &decode, &operand) != X86EMUL_OKAY ) - return X86EMUL_EXCEPTION; + rc = decode_vmx_inst(regs, &decode, &operand); + if ( rc != X86EMUL_OKAY ) + return rc; if ( !vvmcx_valid(v) ) { @@ -1905,10 +1906,7 @@ static int nvmx_handle_vmwrite(struct cpu_user_regs *regs) break; } - if ( okay ) - vmsucceed(regs); - else - vmfail_valid(regs, VMX_INSN_UNSUPPORTED_VMCS_COMPONENT); + vmsucceed(regs); return X86EMUL_OKAY; } -- 2.30.2