From: Marcelo Tosatti Subject: Re: VMX and save/restore guest in virtual-8086 mode Date: Thu, 8 Apr 2010 11:47:14 -0300 Message-ID: <20100408144714.GB20713@amt.cnet> References: <20100407202400.GA29595@amt.cnet> <4BBCEF34.8000607@redhat.com> <4BBD8453.2030405@siemens.com> <4BBD85F1.50900@redhat.com> <4BBD8BBB.3060308@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm , Gleb Natapov To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49943 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758609Ab0DHOuH (ORCPT ); Thu, 8 Apr 2010 10:50:07 -0400 Content-Disposition: inline In-Reply-To: <4BBD8BBB.3060308@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Apr 08, 2010 at 09:54:35AM +0200, Jan Kiszka wrote: > >>>> The following patch fixes it, but it has some drawbacks: > >>>> > >>>> - cpu_synchronize_state+writeback is noticeably slow with tpr patching, > >>>> this makes it slower. > >>>> > >>>> > >>> Isn't it a very rare event? > >>> > >> It has to be - otherwise the decision to go for full sync and individual > >> get/set IOCTL would have been wrong. What happens during tpr patching? > >> > >> > > > > tpr patching listens for instructions which access the tpr and patches > > them to a call instruction (targeting some hacky code in the bios). > > Since there are a limited number of such instructions (20-30 IIRC) you > > expect tpr patching to happen very rarely. > > Then I wonder why it is noticeable. While switching kvm-tpr-opt.c from explicit {get,put}_{s}regs to cpu_synchronize_state+writeback i noticed WinXP.32 boot became visually slower. For some reason, the delay introduced by cpu_synchronize_state+writeback forbids patching certain instructions for longer periods, or somehow allows Windows to use unpatched instructions more often . End result was 4x more patching (from 700 to 4000, roughly). Confirmed it was a timing issue by introducing delays to original {get,put}_{s}regs version. The particular tpr case is no big deal since as mentioned its a short lived period, but for things like Kemari this might be an issue. But this is another discussion.