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@xxxxxxxxxxxxxxxxxxx |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |I work for money. If you want loyalty, http://nadav.harel.org.il |buy yourself a dog. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html