From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 16/24] Implement VMLAUNCH and VMRESUME Date: Sun, 26 Sep 2010 15:51:14 +0200 Message-ID: <4C9F4FD2.5050806@redhat.com> References: <1276431753-nyh@il.ibm.com> <201006131230.o5DCUk2i013070@rice.haifa.ibm.com> <4C161569.3000602@redhat.com> <20100926111412.GC29641@fermat.math.technion.ac.il> <4C9F4316.5090906@redhat.com> <20100926130653.GA13736@fermat.math.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: "Nadav Har'El" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42098 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752061Ab0IZNvU (ORCPT ); Sun, 26 Sep 2010 09:51:20 -0400 In-Reply-To: <20100926130653.GA13736@fermat.math.technion.ac.il> Sender: kvm-owner@vger.kernel.org List-ID: On 09/26/2010 03:06 PM, Nadav Har'El wrote: > On Sun, Sep 26, 2010, Avi Kivity wrote about "Re: [PATCH 16/24] Implement VMLAUNCH and VMRESUME": > > I don't see how vcpu->arch.cr0 can cache cr0_read_shadow. > > But this is precisely what the (unpatched) vmx_set_cr0 code does: > If you look at it, it takes a parameter "cr0" and builds an additional > variable "hw_cr0". > "cr0" gets written into CR0_READ_SHADOW, while "hw_cr0" gets written into > GUEST_CR0. > vcpu->arch.cr0 gets a copy of "cr0", not of "hw_cr0", i.e., it is a cache of > CR0_READ_SHADOW, not of GUEST_CR0. > > Or am I missing something? > In vmx, cr0 is split into two registers, CR0_READ_SHADOW and GUEST_CR0. nvmx needs to split vCR0_READ_SHADOW and vGUEST_CR0 into three. vCR0_READ_SHADOW can be assigned directly to CR0_READ_SHADOW. vGUEST_CR0 can be copied to vcpu->arch.cr0 so the mmu acts according to the mode L1 thinks it places L2 into (but not what L2 thinks it is in). vGUEST_CR0, appropriately munged (by ORing it with KVM_VM_CR0_ALWAYS_ON and doing the TS games) is assigned to GUEST_CR0. We need to audit all code that touches vcpu->arch.cr0; but I think this split is the easiest one. The only code that needs to change is the cr0/lmsw emulation code (writes need to consider vCR0_GUEST_HOST_MASK). -- error compiling committee.c: too many arguments to function