From: Glauber Costa Subject: Re: [PATCH v2 2/2] turn off kvmclock when resetting cpu Date: Wed, 5 May 2010 18:18:57 -0300 Message-ID: <20100505211857.GE3443@mothafucka.localdomain> References: <1273087161-32428-1-git-send-email-glommer@redhat.com> <1273087161-32428-2-git-send-email-glommer@redhat.com> <1273087161-32428-3-git-send-email-glommer@redhat.com> <4BE1D630.5090600@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, avi@redhat.com, mtosatti@redhat.com To: Zachary Amsden Return-path: Received: from mx1.redhat.com ([209.132.183.28]:57431 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756650Ab0EEVTI (ORCPT ); Wed, 5 May 2010 17:19:08 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o45LJ7Dv031927 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 May 2010 17:19:08 -0400 Content-Disposition: inline In-Reply-To: <4BE1D630.5090600@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, May 05, 2010 at 10:33:52AM -1000, Zachary Amsden wrote: > On 05/05/2010 09:19 AM, Glauber Costa wrote: > >Currently, in the linux kernel, we reset kvmclock if we are rebooting > >into a crash kernel through kexec. The rationale, is that a new kernel > >won't follow the same memory addresses, and the memory where kvmclock is > >located in the first kernel, will be something else in the second one. > > > >We don't do it in normal reboots, because the second kernel ends up > >registering kvmclock again, which has the effect of turning off the > >first instance. > > > >This is, however, totally wrong. This assumes we're booting into > >a kernel that also has kvmclock enabled. If by some reason we reboot > >into something that doesn't do kvmclock including but not limited to: > > * rebooting into an older kernel without kvmclock support, > > * rebooting with no-kvmclock, > > * rebootint into another O.S, > > > >we'll simply have the hypervisor writting into a random memory position > >into the guest. Neat, uh? > > > >Moreover, I believe the fix belongs in qemu, since it is the entity > >more prepared to detect all kinds of reboots (by means of a cpu_reset), > >not to mention the presence of misbehaving guests, that can forget > >to turn kvmclock off. > > > >It is also necessary to reset other msrs, so this patch resets > >everything that kvm exports through its MSR list. > > Does that include the TSC? AFAIK, yes.