From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM: VMX: do not overwrite uptodate vcpu->arch.cr3 on KVM_SET_SREGS Date: Tue, 07 Jun 2011 11:24:49 +0300 Message-ID: <4DEDE051.2090908@redhat.com> References: <20110606172747.GA30900@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:43689 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976Ab1FGIYx (ORCPT ); Tue, 7 Jun 2011 04:24:53 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p578Or96007041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 7 Jun 2011 04:24:53 -0400 In-Reply-To: <20110606172747.GA30900@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 06/06/2011 08:27 PM, Marcelo Tosatti wrote: > Only decache guest CR3 value if vcpu->arch.cr3 is stale. > Fixes loadvm with live guest. > > > @@ -2049,7 +2049,9 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, > unsigned long cr0, > struct kvm_vcpu *vcpu) > { > - vmx_decache_cr3(vcpu); > + > + if (!test_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail)) > + vmx_decache_cr3(vcpu); > if (!(cr0& X86_CR0_PG)) { > /* From paging/starting to nonpaging */ > vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, Applied and queued, but I think there is something rotten here. How does arch.cr3 get into GUEST_CR3 after KVM_SET_SREGS? arch.cr3 is a supposed to be write-through cache - it only has a bit in regs_avail, not regs_dirty. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.