From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [PATCH 20 of 20] n2 MSR handling and capability exposure Date: Tue, 26 Jul 2011 12:42:33 +0100 Message-ID: <20110726114233.GJ8970@whitby.uk.xensource.com> References: <1A42CE6F5F474C41B63392A5F80372B212DAB9DD82@shsmsx501.ccr.corp.intel.com> <4E258DC4.4050106@grosc.com> <1A42CE6F5F474C41B63392A5F80372B212DAC025EB@shsmsx501.ccr.corp.intel.com> <4E26E23D.4030000@grosc.com> <20110725140843.GC8970@whitby.uk.xensource.com> <20110725161657.GF8970@whitby.uk.xensource.com> <4E2E6992.9030407@grosc.com> <20110726100018.GH8970@whitby.uk.xensource.com> <20110726101140.GI8970@whitby.uk.xensource.com> <4E2E9B05.7030206@grosc.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="GID0FwUMdk1T2AWN" Return-path: Content-Disposition: inline In-Reply-To: <4E2E9B05.7030206@grosc.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeroen Groenewegen van der Weyden Cc: "Christoph.Egger@amd.com" , "xen-devel@lists.xensource.com" , "Dong, Eddie" List-Id: xen-devel@lists.xenproject.org --GID0FwUMdk1T2AWN Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline At 12:46 +0200 on 26 Jul (1311684389), Jeroen Groenewegen van der Weyden wrote: > Here my input Thanks. Looks very similar to the bug I thought I fixed with my patch. VCPUs 1 and 3 are always at 0xa01a1c9d: <0f> 01 c2 eb 03 0f 01 c3 which is probably this fragment of code from KVM's vmx_vcpu_run(): /* Enter guest mode */ "jne .Llaunched \n\t" __ex(ASM_VMX_VMLAUNCH) "\n\t" "jmp .Lkvm_vmx_return \n\t" ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t" ".Lkvm_vmx_return: " So, just like the case I saw, they're trying to VMLAUNCH a VMCS and failing. That should only fail if the VMCS is already launched. I think the reason they're _stuck_ is that error paths for VMLAUNCH and VMRESUME emulation are wrong; I can fix them up a little but I suspect that won't solve the problem; just change it from a hang to some other failure mode. Can you try the attached patch instead of the previous one? Tim. -- Tim Deegan Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) --GID0FwUMdk1T2AWN Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: attachment; filename="vmclear" diff -r 9dbbf1631193 xen/arch/x86/hvm/vmx/vvmx.c --- a/xen/arch/x86/hvm/vmx/vvmx.c Mon Jul 25 14:21:13 2011 +0100 +++ b/xen/arch/x86/hvm/vmx/vvmx.c Tue Jul 26 12:42:00 2011 +0100 @@ -1070,11 +1070,17 @@ int nvmx_handle_vmresume(struct cpu_user int launched; struct vcpu *v = current; + if ( vcpu_nestedhvm(v).nv_vvmcxaddr == VMCX_EADDR ) + { + vmreturn (regs, VMFAIL_INVALID); + return X86EMUL_OKAY; + } + launched = __get_vvmcs(vcpu_nestedhvm(v).nv_vvmcx, NVMX_LAUNCH_STATE); if ( !launched ) { vmreturn (regs, VMFAIL_VALID); - return X86EMUL_EXCEPTION; + return X86EMUL_OKAY; } return nvmx_vmresume(v,regs); } @@ -1085,11 +1091,17 @@ int nvmx_handle_vmlaunch(struct cpu_user int rc; struct vcpu *v = current; + if ( vcpu_nestedhvm(v).nv_vvmcxaddr == VMCX_EADDR ) + { + vmreturn (regs, VMFAIL_INVALID); + return X86EMUL_OKAY; + } + launched = __get_vvmcs(vcpu_nestedhvm(v).nv_vvmcx, NVMX_LAUNCH_STATE); if ( launched ) { vmreturn (regs, VMFAIL_VALID); - rc = X86EMUL_EXCEPTION; + return X86EMUL_OKAY; } else { rc = nvmx_vmresume(v,regs); @@ -1162,6 +1174,7 @@ int nvmx_handle_vmclear(struct cpu_user_ struct vmx_inst_decoded decode; struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); unsigned long gpa = 0; + void *vvmcs; int rc; rc = decode_vmx_inst(regs, &decode, &gpa, 0); @@ -1176,9 +1189,15 @@ int nvmx_handle_vmclear(struct cpu_user_ if ( gpa != nvcpu->nv_vvmcxaddr && nvcpu->nv_vvmcxaddr != VMCX_EADDR ) { - gdprintk(XENLOG_WARNING, - "vmclear gpa %lx not the same as current vmcs %"PRIpaddr"\n", + gdprintk(XENLOG_WARNING, "vmclear gpa %lx != %"PRIpaddr"\n", gpa, nvcpu->nv_vvmcxaddr); + + /* Even if this VMCS isn't the current one, we must clear it. */ + vvmcs = hvm_map_guest_frame_rw(gpa >> PAGE_SHIFT); + if ( vvmcs ) + __set_vvmcs(vvmcs, NVMX_LAUNCH_STATE, 0); + hvm_unmap_guest_frame(vvmcs); + vmreturn(regs, VMSUCCEED); goto out; } --GID0FwUMdk1T2AWN Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --GID0FwUMdk1T2AWN--