From: "Nadav Har'El" Subject: Re: [PATCH 15/27] nVMX: Prepare vmcs02 from vmcs01 and vmcs12 Date: Tue, 8 Feb 2011 14:13:15 +0200 Message-ID: <20110208121315.GA28897@fermat.math.technion.ac.il> References: <1287309814-nyh@il.ibm.com> <201010171011.o9HABFP1029474@rice.haifa.ibm.com> <4CBB037A.2050906@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, gleb@redhat.com To: Avi Kivity Return-path: Received: from mailgw12.technion.ac.il ([132.68.225.12]:33783 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753842Ab1BHMNT (ORCPT ); Tue, 8 Feb 2011 07:13:19 -0500 Content-Disposition: inline In-Reply-To: <4CBB037A.2050906@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Oct 17, 2010, Avi Kivity wrote about "Re: [PATCH 15/27] nVMX: Prepare vmcs02 from vmcs01 and vmcs12": > On 10/17/2010 12:11 PM, Nadav Har'El wrote: > >This patch contains code to prepare the VMCS which can be used to actually > >run the L2 guest, vmcs02. prepare_vmcs02 appropriately merges the > >information > >in vmcs12 (the vmcs that L1 built for L2) and in vmcs01 (the vmcs that we > >built for L1). > > > >VMREAD/WRITE can only access one VMCS at a time (the "current" VMCS), which > >makes it difficult for us to read from vmcs01 while writing to vmcs12. This > >is why we first make a copy of vmcs01 in memory (vmcs01_fields) and then > >read that memory copy while writing to vmcs12. > > > > I believe I commented on this before - you can call the same functions > kvm uses to initialize the normal vmcs to get the common parts filled > in. Hi, I'm finally attending to this issue, and you're right, for almost all fields there's hardly a reason to read them from VMCS into a memory structure vmcs01, when it was KVM who set these fields in the first place and can set them again when needed in vmcs02. I'm slowly removing the fields in the vmcs01 in- memory structure (only about a dozen left at this point!), and finally the "vmcs12" structure contains all its fields, without another substructure (as you asked once). But while doing this, I came across a question that I wonder if you can clarify for me: Among the other things it sets up, vmx_vcpu_setup() sets rdmsrl(MSR_IA32_SYSENTER_ESP, a); vmcs_writel(HOST_IA32_SYSENTER_ESP, a); /* 22.2.3 */ Why is this needed here? In vmx_vcpu_load(), when a cpu is known (or changed), we again have: rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ So isn't the first setting, in vmx_vcpu_setup(), redundant? Thanks, Nadav. -- Nadav Har'El | Tuesday, Feb 8 2011, 4 Adar I 5771 nyh@math.technion.ac.il |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |Earth First! We can strip-mine the other http://nadav.harel.org.il |planets later...