From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH v3] KVM: nVMX: Fix setting of CR0 and CR4 in guest mode Date: Thu, 7 Mar 2013 15:49:09 -0300 Message-ID: <20130307184909.GA15649@amt.cnet> References: <51389137.5030606@siemens.com> <20130307133214.GL11223@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jan Kiszka , kvm , "Nadav Har'El" , "Nakajima, Jun" To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2997 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756835Ab3CGTJO (ORCPT ); Thu, 7 Mar 2013 14:09:14 -0500 Content-Disposition: inline In-Reply-To: <20130307133214.GL11223@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Mar 07, 2013 at 03:32:14PM +0200, Gleb Natapov wrote: > On Thu, Mar 07, 2013 at 02:08:07PM +0100, Jan Kiszka wrote: > > The logic for calculating the value with which we call kvm_set_cr0/4 was > > broken (will definitely be visible with nested unrestricted guest mode > > support). Also, we performed the check regarding CR0_ALWAYSON too early > > when in guest mode. > > > > What really needs to be done on both CR0 and CR4 is to mask out L1-owned > > bits and merge them in from L1's guest_cr0/4. In contrast, arch.cr0/4 > > and arch.cr0/4_guest_owned_bits contain the mangled L0+L1 state and, > > thus, are not suited as input. > > > > For both CRs, we can then apply the check against VMXON_CRx_ALWAYSON and > > refuse the update if it fails. To be fully consistent, we implement this > > check now also for CR4. For CR4, we move the check into vmx_set_cr4 > > while we keep it in handle_set_cr0. This is because the CR0 checks for > > vmxon vs. guest mode will diverge soon when adding unrestricted guest > > mode support. > > > > Finally, we have to set the shadow to the value L2 wanted to write > > originally. > > > > Signed-off-by: Jan Kiszka > Reviewed-by: Gleb Natapov Applied, thanks.