From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nadav Har'El" Subject: Re: [PATCH 07/31] nVMX: Introduce vmcs02: VMCS used to run L2 Date: Sun, 22 May 2011 10:22:31 +0300 Message-ID: <20110522072231.GA186@fermat.math.technion.ac.il> References: <1305575004-nyh@il.ibm.com> <201105161947.p4GJlUJb001735@rice.haifa.ibm.com> <625BA99ED14B2D499DC4E29D8138F1505C9BEEFE29@shsmsx502.ccr.corp.intel.com> <625BA99ED14B2D499DC4E29D8138F1505C9BEEFE8F@shsmsx502.ccr.corp.intel.com> <20110520203211.GA5519@fermat.math.technion.ac.il> <625BA99ED14B2D499DC4E29D8138F1505C9BEEFFD8@shsmsx502.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "kvm@vger.kernel.org" , "gleb@redhat.com" , "avi@redhat.com" To: "Tian, Kevin" Return-path: Received: from mailgw12.technion.ac.il ([132.68.225.12]:4153 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752243Ab1EVHWk (ORCPT ); Sun, 22 May 2011 03:22:40 -0400 Content-Disposition: inline In-Reply-To: <625BA99ED14B2D499DC4E29D8138F1505C9BEEFFD8@shsmsx502.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Hi, On Sun, May 22, 2011, Tian, Kevin wrote about "RE: [PATCH 07/31] nVMX: Introduce vmcs02: VMCS used to run L2": > Here the vmcs02 being overridden may have been run on another processor before > but is not vmclear-ed yet. When you resume this vmcs02 with new content on a > separate processor, the risk of corruption exists. I still believe that my current code is correct (in this area). I'll try to explain it here and would be grateful if you could point to me the error (if there is one) in my logic: Nested_vmx_run() is our function which is switches from running L1 to L2 (patch 18). This function starts by calling nested_get_current_vmcs02(), which gets us *some* vmcs to use for vmcs02. This may be a fresh new VMCS, or a "recycled" VMCS, some VMCS we've previously used to run some, potentially different L2 guest on some, potentially different, CPU. nested_get_current_vmcs02() returns a "saved_vmcs" structure, which not only contains a VMCS, but also remembers on which (if any) cpu it is currently loaded (and whether it was VMLAUNCHed once on that cpu). The next thing that Nested_vmx_run() now does is to set up in the vcpu object the vmcs, cpu and launched fields according to what was returned above. Now it calls vmx_vcpu_load(). This standard KVM function checks if we're now running on a different CPU from the vcpu->cpu, and if it a different one, is uses vcpu_clear() to VMCLEAR the vmcs on the CPU where it was last loaded (using an IPI). Only after it vmclears the VMCS on the old CPU, it can finally load the VMCS on the new CPU. Only now Nested_vmx_run() can call prepare_vmcs02, which starts VMWRITEing to this VMCS, and finally returns. P.S. Seeing that you're from Intel, maybe you can help me with a pointer: I found what appears to be a small error in the SDM - who can I report it to? Thanks, Nadav. -- Nadav Har'El | Sunday, May 22 2011, 18 Iyyar 5771 nyh@math.technion.ac.il |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |I work for money. If you want loyalty, http://nadav.harel.org.il |buy yourself a dog.