From: "Robert Phillips" Subject: vmcs GUEST_CR0 unused? Date: Thu, 1 Feb 2007 16:49:55 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1868208007==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============1868208007== Content-Type: multipart/alternative; boundary="----=_Part_8440_13828102.1170366595265" ------=_Part_8440_13828102.1170366595265 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Why does the vmx code maintain hvm_vmx.cpu_cr0? I see code in vmx.c that keeps v->arch.hvm_vmx.cpu_cr0 up to date, and each change is faithfully written to the vmcs using __vmwrite(GUEST_CR0, ...) I also see that the CR0_GUEST_HOST_MASK is always all ones (~0UL), set in construct_vmcs() and never modified. However according to section 2.6.6 of the VT specification the value in GUEST_CR0 is irrelevant if CR0_GUEST_HOST_MASK is all ones. When the guest reads CR0, the mask will force it to see only the bits in CR0_READ_SHADOW. When the guest modifies CR0, the mask will force a vmexit. So the vmcs value in GUEST_CR0 is never visible to the guest and never really needed by the host. It looks to me like the code that maintains hvm_vmx.cpu_cr0 and GUEST_CR0 is superfluous. The same argument applies to hvm_vmx.cup_cr4 and GUEST_CR4. Am I missing something? -- -------------------------------------------------------------------- Robert S. Phillips Virtual Iron Software rphillips@virtualiron.com Tower 1, Floor 2 978-849-1220 900 Chelmsford Street Lowell, MA 01851 ------=_Part_8440_13828102.1170366595265 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Why does the vmx code maintain hvm_vmx.cpu_cr0?

I see code in vmx.c that keeps v->arch.hvm_vmx.cpu_cr0 up to date, and each change is faithfully written to the vmcs using __vmwrite(GUEST_CR0, ...)
I also see that the CR0_GUEST_HOST_MASK is always all ones (~0UL), set in construct_vmcs() and never modified.

However according to section 2.6.6 of the VT specification the value in GUEST_CR0 is irrelevant if CR0_GUEST_HOST_MASK is all ones.
When the guest reads CR0, the mask will force it to see only the bits in CR0_READ_SHADOW.
When the guest modifies CR0, the mask will force a vmexit.

So the vmcs value in GUEST_CR0 is never visible to the guest and never really needed by the host.

It looks to me like the code that maintains hvm_vmx.cpu_cr0 and GUEST_CR0 is superfluous.

The same argument applies to hvm_vmx.cup_cr4 and GUEST_CR4.

Am I missing something?

--
--------------------------------------------------------------------
Robert S. Phillips                          Virtual Iron Software
rphillips@virtualiron.com                Tower 1, Floor 2
978-849-1220                                 900 Chelmsford Street
                                                    Lowell, MA 01851 ------=_Part_8440_13828102.1170366595265-- --===============1868208007== 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 --===============1868208007==--